XmlWriter.WriteName(String) 方法

定义

当在派生类中被重写时,写出指定的名称,确保它是符合 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:
 abstract void WriteName(System::String ^ name);
public virtual void WriteName (string name);
public abstract void WriteName (string name);
abstract member WriteName : string -> unit
override this.WriteName : string -> unit
abstract member WriteName : string -> unit
Public Overridable Sub WriteName (name As String)
Public MustOverride Sub WriteName (name As String)

参数

name
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 还会根据 XML 中的 W3C 命名空间建议检查该名称是否有效。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.

适用于