XmlReader::Read Method
When overridden in a derived class, reads the next node from the stream.
Assembly: System.Xml (in System.Xml.dll)
Return Value
Type: System::Booleantrue if the next node was read successfully; false if there are no more nodes to read.
| Exception | Condition |
|---|---|
| XmlException | An error occurred while parsing the XML. |
When an XmlReader is first created and initialized, there is no information available. You must call Read to read the first node.
This method requires at least four bytes from the data stream in order to begin parsing. If fewer than four bytes are returned and there is no more data in the stream, the method will fail. If there is more data in the stream, the method will block parsing until receipt of the fourth byte.
The following example reads an XML file and displays each of the nodes.
The sample uses the items.xml file.
<?xml version="1.0"?> <!-- This is a sample XML document --> <!DOCTYPE Items [<!ENTITY number "123">]> <Items> <Item>Test with an entity: &number;</Item> <Item>Test with a child element <more/> stuff</Item> <Item>Test with a CDATA section <![CDATA[<456>]]> def</Item> <Item>Test with a char entity: A</Item> <!-- Fourteen chars in this element.--> <Item>1234567890ABCD</Item> </Items>
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.