XmlReader.ReadElementString XmlReader.ReadElementString XmlReader.ReadElementString XmlReader.ReadElementString Method

定义

读取只有简单文本的元素。Reads the simple text-only elements. 但是,建议改用 ReadElementContentAsString 方法,因为该方法可以更直接地处理此操作。However, we recommend that you use the ReadElementContentAsString method instead, because it provides a more straightforward way to handle this operation.

重载

ReadElementString() ReadElementString() ReadElementString() ReadElementString()

读取纯文本元素。Reads a text-only element. 但是,建议改用 ReadElementContentAsString() 方法,因为该方法可以更直接地处理此操作。However, we recommend that you use the ReadElementContentAsString() method instead, because it provides a more straightforward way to handle this operation.

ReadElementString(String) ReadElementString(String) ReadElementString(String) ReadElementString(String)

在读取纯文本元素之前,检查所找到元素的 Name 属性是否与给定的字符串匹配。Checks that the Name property of the element found matches the given string before reading a text-only element. 但是,建议改用 ReadElementContentAsString() 方法,因为该方法可以更直接地处理此操作。However, we recommend that you use the ReadElementContentAsString() method instead, because it provides a more straightforward way to handle this operation.

ReadElementString(String, String) ReadElementString(String, String) ReadElementString(String, String) ReadElementString(String, String)

在读取纯文本元素之前,检查所找到元素的 LocalNameNamespaceURI 属性是否与给定的字符串匹配。Checks that the LocalName and NamespaceURI properties of the element found matches the given strings before reading a text-only element. 但是,建议改用 ReadElementContentAsString(String, String) 方法,因为该方法可以更直接地处理此操作。However, we recommend that you use the ReadElementContentAsString(String, String) method instead, because it provides a more straightforward way to handle this operation.

注解

建议使用ReadElementContentAsString方法读取文本元素。We recommend that you use the ReadElementContentAsString method to read a text element.

ReadElementString() ReadElementString() ReadElementString() ReadElementString()

读取纯文本元素。Reads a text-only element. 但是,建议改用 ReadElementContentAsString() 方法,因为该方法可以更直接地处理此操作。However, we recommend that you use the ReadElementContentAsString() method instead, because it provides a more straightforward way to handle this operation.

public:
 virtual System::String ^ ReadElementString();
public virtual string ReadElementString ();
abstract member ReadElementString : unit -> string
override this.ReadElementString : unit -> string
Public Overridable Function ReadElementString () As String

返回

所读取的元素中包含的文本。The text contained in the element that was read. 如果元素为空,则返回一个空字符串。An empty string if the element is empty.

异常

下一个内容节点不是开始标记;或者找到的元素不包含简单文本值。The next content node is not a start tag; or the element found does not contain a simple text value.

在上一次异步操作完成之前调用了 XmlReader 方法。An XmlReader 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."

注解

建议使用ReadElementContentAsString()方法读取文本元素。We recommend that you use the ReadElementContentAsString() method to read a text element.

ReadElementString(String) ReadElementString(String) ReadElementString(String) ReadElementString(String)

在读取纯文本元素之前,检查所找到元素的 Name 属性是否与给定的字符串匹配。Checks that the Name property of the element found matches the given string before reading a text-only element. 但是,建议改用 ReadElementContentAsString() 方法,因为该方法可以更直接地处理此操作。However, we recommend that you use the ReadElementContentAsString() method instead, because it provides a more straightforward way to handle this operation.

public:
 virtual System::String ^ ReadElementString(System::String ^ name);
public virtual string ReadElementString (string name);
abstract member ReadElementString : string -> string
override this.ReadElementString : string -> string
Public Overridable Function ReadElementString (name As String) As String

参数

name
String String String String

要检查的名称。The name to check.

返回

所读取的元素中包含的文本。The text contained in the element that was read. 如果元素为空,则返回一个空字符串。An empty string if the element is empty.

异常

如果下一个内容节点不是一个开始标记;如果元素 Name 与给定的参数不匹配;或者如果找到的元素不包含简单的文本值。If the next content node is not a start tag; if the element Name does not match the given argument; or if the element found does not contain a simple text value.

在上一次异步操作完成之前调用了 XmlReader 方法。An XmlReader 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."

注解

建议使用ReadElementContentAsString()方法读取文本元素。We recommend that you use the ReadElementContentAsString() method to read a text element.

ReadElementString(String, String) ReadElementString(String, String) ReadElementString(String, String) ReadElementString(String, String)

在读取纯文本元素之前,检查所找到元素的 LocalNameNamespaceURI 属性是否与给定的字符串匹配。Checks that the LocalName and NamespaceURI properties of the element found matches the given strings before reading a text-only element. 但是,建议改用 ReadElementContentAsString(String, String) 方法,因为该方法可以更直接地处理此操作。However, we recommend that you use the ReadElementContentAsString(String, String) method instead, because it provides a more straightforward way to handle this operation.

public:
 virtual System::String ^ ReadElementString(System::String ^ localname, System::String ^ ns);
public virtual string ReadElementString (string localname, string ns);
abstract member ReadElementString : string * string -> string
override this.ReadElementString : string * string -> string
Public Overridable Function ReadElementString (localname As String, ns As String) As String

参数

localname
String String String String

要检查的本地名称。The local name to check.

ns
String String String String

要检查的命名空间 URI。The namespace URI to check.

返回

所读取的元素中包含的文本。The text contained in the element that was read. 如果元素为空,则返回一个空字符串。An empty string if the element is empty.

异常

如果下一个内容节点不是一个开始标记;如果元素 LocalNameNamespaceURI 与给定的参数不匹配;或者如果找到的元素不包含简单的文本值。If the next content node is not a start tag; if the element LocalName or NamespaceURI do not match the given arguments; or if the element found does not contain a simple text value.

在上一次异步操作完成之前调用了 XmlReader 方法。An XmlReader 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."

注解

建议使用ReadElementContentAsString(String, String)方法读取文本元素。We recommend that you use the ReadElementContentAsString(String, String) method to read a text element.

适用于