XmlWriter.WriteStartAttribute XmlWriter.WriteStartAttribute XmlWriter.WriteStartAttribute XmlWriter.WriteStartAttribute Method

定義

在衍生類別中覆寫時,寫入屬性的開頭。When overridden in a derived class, writes the start of an attribute.

多載

WriteStartAttribute(String, String, String) WriteStartAttribute(String, String, String) WriteStartAttribute(String, String, String) WriteStartAttribute(String, String, String)

在衍生類別中覆寫時,寫入具有指定的前置詞、區域名稱和命名空間 URI 之屬性的開頭。When overridden in a derived class, writes the start of an attribute with the specified prefix, local name, and namespace URI.

WriteStartAttribute(String) WriteStartAttribute(String) WriteStartAttribute(String) WriteStartAttribute(String)

寫入具有指定之區域名稱的屬性開頭。Writes the start of an attribute with the specified local name.

WriteStartAttribute(String, String) WriteStartAttribute(String, String) WriteStartAttribute(String, String) WriteStartAttribute(String, String)

寫入具有指定之區域名稱和命名空間 URI 之屬性的開頭。Writes the start of an attribute with the specified local name and namespace URI.

備註

這個方法的非同步版本,請參閱WriteStartAttributeAsyncFor the asynchronous version of this method, see WriteStartAttributeAsync.

WriteStartAttribute(String, String, String) WriteStartAttribute(String, String, String) WriteStartAttribute(String, String, String) WriteStartAttribute(String, String, String)

在衍生類別中覆寫時,寫入具有指定的前置詞、區域名稱和命名空間 URI 之屬性的開頭。When overridden in a derived class, writes the start of an attribute with the specified prefix, local name, and namespace URI.

public:
 abstract void WriteStartAttribute(System::String ^ prefix, System::String ^ localName, System::String ^ ns);
public abstract void WriteStartAttribute (string prefix, string localName, string ns);
abstract member WriteStartAttribute : string * string * string -> unit
Public MustOverride Sub WriteStartAttribute (prefix As String, localName As String, ns As String)

參數

prefix
String String String String

屬性的命名空間前置詞。The namespace prefix of the attribute.

localName
String String String String

屬性的本機名稱。The local name of the attribute.

ns
String String String String

屬性的命名空間 URI。The namespace URI for the attribute.

例外狀況

緩衝區中有一個字元,其為有效的 XML 字元,但對輸出編碼而言無效。There is a character in the buffer that is a valid XML character but is not valid for the output encoding. 比方說如果輸出的編碼方式為 ASCII,您應該在項目與屬性名稱中只使用範圍從 0 至 127 的字元。For example, if the output encoding is ASCII, you should only use characters from the range of 0 to 127 for element and attribute names. 無效的字元可能是在這個方法的引數中,或在先前已寫入至緩衝區的方法的引數中。The invalid character might be in the argument of this method or in an argument of previous methods that were writing to the buffer. 字元實體參考會盡可能逸出這類字元 (比方說在文字節點或屬性值中)。Such characters are escaped by character entity references when possible (for example, in text nodes or attribute values). 不過,在項目與屬性名稱、註解、處理指示或 CDATA 區段中不允許字元實體參考。However, the character entity reference is not allowed in element and attribute names, comments, processing instructions, or CDATA sections.

在先前的非同步作業完成前呼叫了 XmlWriter 方法。An XmlWriter method was called before a previous asynchronous operation finished. 在此情況下,會擲回 InvalidOperationException 與「非同步作業已經在進行中」的訊息。In this case, InvalidOperationException is thrown with the message "An asynchronous operation is already in progress."

備註

這個方法可讓您撰寫使用多個寫入方法的值。This method enables you to write a value using multiple Write methods.

這個方法的非同步版本,請參閱WriteStartAttributeAsyncFor the asynchronous version of this method, see WriteStartAttributeAsync.

WriteStartAttribute(String) WriteStartAttribute(String) WriteStartAttribute(String) WriteStartAttribute(String)

寫入具有指定之區域名稱的屬性開頭。Writes the start of an attribute with the specified local name.

public:
 void WriteStartAttribute(System::String ^ localName);
public void WriteStartAttribute (string localName);
member this.WriteStartAttribute : string -> unit
Public Sub WriteStartAttribute (localName As String)

參數

localName
String String String String

屬性的本機名稱。The local name of the attribute.

例外狀況

寫入器已關閉。The writer is closed.

-或--or-

在先前的非同步作業完成前呼叫了 XmlWriter 方法。An XmlWriter method was called before a previous asynchronous operation finished. 在此情況下,會擲回 InvalidOperationException 與「非同步作業已經在進行中」的訊息。In this case, InvalidOperationException is thrown with the message "An asynchronous operation is already in progress."

緩衝區中有一個字元,其為有效的 XML 字元,但對輸出編碼而言無效。There is a character in the buffer that is a valid XML character but is not valid for the output encoding. 比方說如果輸出的編碼方式為 ASCII,您應該在項目與屬性名稱中只使用範圍從 0 至 127 的字元。For example, if the output encoding is ASCII, you should only use characters from the range of 0 to 127 for element and attribute names. 無效的字元可能是在這個方法的引數中,或在先前已寫入至緩衝區的方法的引數中。The invalid character might be in the argument of this method or in an argument of previous methods that were writing to the buffer. 字元實體參考會盡可能逸出這類字元 (比方說在文字節點或屬性值中)。Such characters are escaped by character entity references when possible (for example, in text nodes or attribute values). 不過,在項目與屬性名稱、註解、處理指示或 CDATA 區段中不允許字元實體參考。However, the character entity reference is not allowed in element and attribute names, comments, processing instructions, or CDATA sections.

備註

這個方法可讓您撰寫使用多個寫入方法的值。This method enables you to write a value using multiple Write methods.

這個方法的非同步版本,請參閱WriteStartAttributeAsyncFor the asynchronous version of this method, see WriteStartAttributeAsync.

WriteStartAttribute(String, String) WriteStartAttribute(String, String) WriteStartAttribute(String, String) WriteStartAttribute(String, String)

寫入具有指定之區域名稱和命名空間 URI 之屬性的開頭。Writes the start of an attribute with the specified local name and namespace URI.

public:
 void WriteStartAttribute(System::String ^ localName, System::String ^ ns);
public void WriteStartAttribute (string localName, string ns);
member this.WriteStartAttribute : string * string -> unit
Public Sub WriteStartAttribute (localName As String, ns As String)

參數

localName
String String String String

屬性的本機名稱。The local name of the attribute.

ns
String String String String

屬性的命名空間 URI。The namespace URI of the attribute.

例外狀況

緩衝區中有一個字元,其為有效的 XML 字元,但對輸出編碼而言無效。There is a character in the buffer that is a valid XML character but is not valid for the output encoding. 比方說如果輸出的編碼方式為 ASCII,您應該在項目與屬性名稱中只使用範圍從 0 至 127 的字元。For example, if the output encoding is ASCII, you should only use characters from the range of 0 to 127 for element and attribute names. 無效的字元可能是在這個方法的引數中,或在先前已寫入至緩衝區的方法的引數中。The invalid character might be in the argument of this method or in an argument of previous methods that were writing to the buffer. 字元實體參考會盡可能逸出這類字元 (比方說在文字節點或屬性值中)。Such characters are escaped by character entity references when possible (for example, in text nodes or attribute values). 不過,在項目與屬性名稱、註解、處理指示或 CDATA 區段中不允許字元實體參考。However, the character entity reference is not allowed in element and attribute names, comments, processing instructions, or CDATA sections.

在先前的非同步作業完成前呼叫了 XmlWriter 方法。An XmlWriter method was called before a previous asynchronous operation finished. 在此情況下,會擲回 InvalidOperationException 與「非同步作業已經在進行中」的訊息。In this case, InvalidOperationException is thrown with the message "An asynchronous operation is already in progress."

範例

請參閱XmlTextWriter.WriteStartAttribute如需使用此方法的範例。See XmlTextWriter.WriteStartAttribute for an example using this method.

備註

這是更進階的版本WriteAttributeString,可讓您撰寫使用多個寫入方法,如屬性值WriteStringWriteQualifiedName,依此類推。This is a more advanced version of WriteAttributeString that allows you to write an attribute value using multiple write methods, such as WriteString, WriteQualifiedName, and so on.

這個方法的非同步版本,請參閱WriteStartAttributeAsyncFor the asynchronous version of this method, see WriteStartAttributeAsync.

另請參閱

適用於