XmlNodeReader::MoveToNextAttribute Method ()
Moves to the next attribute.
Assembly: System.Xml (in System.Xml.dll)
Return Value
Type: System::Booleantrue if there is a next attribute; false if there are no more attributes.
Note |
|---|
In the .NET Framework 2.0, the recommended practice is to create XmlReader instances using the XmlReaderSettings class and the Create method. This allows you to take full advantage of all the new features introduced in the .NET Framework. For more information, see the Remarks section in the XmlReader reference page. |
If the current node is not an attribute node, this method is equivalent to MoveToFirstAttribute. If MoveToNextAttribute returns true, the reader moves to the next attribute; otherwise, the position of the reader does not change.
The following example reads a book.
#using <System.Xml.dll> using namespace System; using namespace System::IO; using namespace System::Xml; int main() { XmlNodeReader^ reader = nullptr; try { //Create and load the XML document. XmlDocument^ doc = gcnew XmlDocument; doc->LoadXml( "<book genre='novel' ISBN='1-861003-78'> " "<title>Pride And Prejudice</title>" "<price>19.95</price>" "</book>" ); //Load the XmlNodeReader reader = gcnew XmlNodeReader( doc ); //Read the attributes on the book element. reader->MoveToContent(); while ( reader->MoveToNextAttribute() ) { Console::WriteLine( "{0} = {1}", reader->Name, reader->Value ); } //Move the reader to the title element. reader->Read(); //Read the title and price elements. Console::WriteLine( reader->ReadElementString() ); Console::WriteLine( reader->ReadElementString() ); } finally { if ( reader != nullptr ) reader->Close(); } }
Available since 1.1
