XmlWriter.WriteName(String) XmlWriter.WriteName(String) XmlWriter.WriteName(String) XmlWriter.WriteName(String) Method

定義

當覆寫衍生類別時,請寫出指定的名稱,以確保它是符合 W3C XML 1.0 建議 (https://www.w3.org/TR/1998/REC-xml-19980210#NT-Name) (英文) 的有效名稱。When overridden in a derived class, writes out the specified name, ensuring it is a valid name according to the W3C XML 1.0 recommendation (https://www.w3.org/TR/1998/REC-xml-19980210#NT-Name).

public:
 virtual void WriteName(System::String ^ name);
public virtual void WriteName (string name);
abstract member WriteName : string -> unit
override this.WriteName : string -> unit
Public Overridable Sub WriteName (name As String)

參數

name
String String String String

要寫入的名稱。The name to write.

例外狀況

name 不是有效的 XML 名稱,或者 namenullString.Emptyname is not a valid XML name; or name is either null or String.Empty.

在先前的非同步作業完成前呼叫了 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."

備註

如果Namespaces設定為trueWriteName也會檢查名稱是否有效,根據 W3C Namespaces in XML 建議事項。If Namespaces is set to true, WriteName also checks that the name is also valid according to the W3C Namespaces in XML recommendation.

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

適用於