Returns a new XmlReader instance that can be used to read the current node, and all its descendants.
Assembly: System.Xml (in System.Xml.dll)
The XmlReader is not positioned on an element when this method is called.
An XmlReader method was called before a previous asynchronous operation finished. In this case, InvalidOperationException is thrown with the message “An asynchronous operation is already in progress.”
can be called only on element nodes. When the entire sub-tree has been read, calls to the Read method returns false. When the new XmlReader has been closed, the original XmlReader will be positioned on the EndElement node of the sub-tree. Thus, if you called the method on the start tag of the book element, after the sub-tree has been read and the new XmlReader has been closed, the original XmlReader is positioned on the end tag of the book element.
You should not perform any operations on the original XmlReader until the new XmlReader has been closed. This action is not supported and can result in unpredictable behavior.
The method is not intended to create a copy of the XML data that you can work with independently. Rather, it can be used create a boundary around an XML element. This is useful if you need to pass data to another component for processing and you wish to limit how much of your data the component can access. When you pass an XmlReader returned by the method to another application, the application can access only that XML element, rather than the entire XML document.
The following example shows how to use the method.
Use the following XML data to run the examples in this topic:
<?xml version="1.0" encoding="utf-8" ?> <Books> <Book> <Title>A Brief History of Time</Title> </Book> <Book> <Title>Principle Of Relativity</Title> </Book> <Book> <Title>Victory of Reason</Title> </Book> <Book> <Title>The Unicorn that did not Fail</Title> </Book> <Book> <Title>Rational Ontology</Title> </Book> <Book> <Title>The Meaning of Pizza</Title> </Book> </Books>
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.