XmlReader.ReadToFollowing 方法

定义

一直读取,直到找到命名元素。Reads until the named element is found.

重载

ReadToFollowing(String)

一直读取,直到找到具有指定限定名的元素。Reads until an element with the specified qualified name is found.

ReadToFollowing(String, String)

一直读取,直到找到具有指定的本地名称和命名空间 URI 的元素。Reads until an element with the specified local name and namespace URI is found.

ReadToFollowing(String)

一直读取,直到找到具有指定限定名的元素。Reads until an element with the specified qualified name is found.

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

参数

name
String

元素的限定名。The qualified name of the element.

返回

Boolean

如果找到匹配的元素,则为 true;否则为 falseXmlReader 位于文件的末尾。true if a matching element is found; otherwise false and the XmlReader is in an end of file state.

例外

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

参数是空字符串。The parameter is an empty string.

注解

此方法在功能上等效于 following::name 从当前节点执行 XPath 表达式。This method is functionally equivalent executing the following::name XPath expression from the current node. 它提供了一种在 XML 文档中查找命名元素的快捷方法。It provides a quick way to find a named element in the XML document. 它将读取器前进到与指定名称匹配的下一个元素, true 如果找到匹配的元素,则返回。It advances the reader to the next following element that matches the specified name and returns true if a matching element is found. 使用下面的示例,读取器将读取到指定元素的第一个实例,同时读取。Using the example below, the reader would read to the first instance of the specified element while reading forward.

<!--"sample.xml"-->  
<?xml version="1.0">  
   <items>  
      <item xmls="urn:1"/>  
   </items>  
</xml>  
XmlTextReader reader = newXmlTextReader("sample.xml");  

reader.ReadToFollowing("item");  

可以在所有节点类型上调用此方法。This method can be called on all node types.

适用于

ReadToFollowing(String, String)

一直读取,直到找到具有指定的本地名称和命名空间 URI 的元素。Reads until an element with the specified local name and namespace URI is found.

public:
 virtual bool ReadToFollowing(System::String ^ localName, System::String ^ namespaceURI);
public virtual bool ReadToFollowing (string localName, string namespaceURI);
abstract member ReadToFollowing : string * string -> bool
override this.ReadToFollowing : string * string -> bool
Public Overridable Function ReadToFollowing (localName As String, namespaceURI As String) As Boolean

参数

localName
String

元素的本地名称。The local name of the element.

namespaceURI
String

元素的命名空间 URI。The namespace URI of the element.

返回

Boolean

如果找到匹配的元素,则为 true;否则为 falseXmlReader 位于文件的末尾。true if a matching element is found; otherwise false and the XmlReader is in an end of file state.

例外

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

两个参数值均为 nullBoth parameter values are null.

注解

此方法在功能上等效于 following::name 从当前节点执行 XPath 表达式。This method is functionally equivalent executing the following::name XPath expression from the current node. 它提供了一种在 XML 文档中查找命名元素的快捷方法。It provides a quick way to find a named element in the XML document. 它将读取器前进到与指定名称匹配的下一个元素, true 如果找到匹配的元素,则返回。It advances the reader to the next following element that matches the specified name and returns true if a matching element is found.

<!--"sample.xml"-->  
<?xml version="1.0">  
   <items>  
      <item xmls="urn:1"/>  
   </items>  
</xml>  
XmlTextReader reader = newXmlTextReader("sample.xml");  

reader.ReadToFollowing("item", "urn:1");  

可以在所有节点类型上调用此方法。This method can be called on all node types.

适用于