Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Wechselt zum nächsten Attribut.
Namespace: System.Xml
Assembly: System.Xml (in system.xml.dll)
Syntax
'Declaration
Public Overrides Function MoveToNextAttribute As Boolean
'Usage
Dim instance As XmlNodeReader
Dim returnValue As Boolean
returnValue = instance.MoveToNextAttribute
public override bool MoveToNextAttribute ()
public:
virtual bool MoveToNextAttribute () override
public boolean MoveToNextAttribute ()
public override function MoveToNextAttribute () : boolean
Rückgabewert
true, wenn ein nächstes Attribut vorhanden ist; false, wenn keine weiteren Attribute vorhanden sind.
Hinweise
Hinweis
Die empfohlene Vorgehensweise für Microsoft .NET Framework, Version 2.0 besteht darin, XmlReader-Instanzen mithilfe der XmlReaderSettings-Klasse und der Create-Methode zu erstellen. Dies erlaubt es, alle Vorteile der neu in .NET Framework enthaltenen Features zu nutzen. Weitere Informationen finden Sie unter Erstellen von XML-Readern.
Wenn der aktuelle Knoten kein Attributknoten ist, sind diese Methode und MoveToFirstAttribute äquivalent. Wenn MoveToNextAttributetrue zurückgibt, wechselt der Reader zum nächsten Attribut, andernfalls bleibt die Position des Readers unverändert.
Beispiel
Im folgenden Beispiel wird ein Buch gelesen.
Option Explicit
Option Strict
Imports System
Imports System.IO
Imports System.Xml
Public Class Sample
Public Shared Sub Main()
Dim reader As XmlNodeReader = Nothing
Try
'Create and load the XML document.
Dim doc As New XmlDocument()
doc.LoadXml("<book genre='novel' ISBN='1-861003-78'> " & _
"<title>Pride And Prejudice</title>" & _
"<price>19.95</price>" & _
"</book>")
'Load the XmlNodeReader
reader = New XmlNodeReader(doc)
'Read the attributes on the book element.
reader.MoveToContent()
While reader.MoveToNextAttribute()
Console.WriteLine("{0} = {1}", reader.Name, reader.Value)
End While
'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 Not (reader Is Nothing) Then
reader.Close()
End If
End Try
End Sub 'Main ' End class
End Class 'Sample
using System;
using System.IO;
using System.Xml;
public class Sample
{
public static void Main()
{
XmlNodeReader reader = null;
try
{
//Create and load the XML document.
XmlDocument doc = new XmlDocument();
doc.LoadXml("<book genre='novel' ISBN='1-861003-78'> " +
"<title>Pride And Prejudice</title>" +
"<price>19.95</price>" +
"</book>");
//Load the XmlNodeReader
reader = new 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 != null)
reader.Close();
}
}
} // End class
#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();
}
}
import System.*;
import System.IO.*;
import System.Xml.*;
public class Sample
{
public static void main(String[] args)
{
XmlNodeReader reader = null;
try {
//Create and load the XML document.
XmlDocument doc = new XmlDocument();
doc.LoadXml("<book genre='novel' ISBN='1-861003-78'> "
+ "<title>Pride And Prejudice</title>"
+ "<price>19.95</price>"
+ "</book>");
//Load the XmlNodeReader
reader = new XmlNodeReader(doc);
//Read the attributes on the book element.
reader.MoveToContent();
while (reader.MoveToNextAttribute()) {
Console.WriteLine("{0} = {1}", reader.get_Name(),
reader.get_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 != null) {
reader.Close();
}
}
} //main
} //End class Sample
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
.NET Compact Framework
Unterstützt in: 2.0, 1.0
Siehe auch
Referenz
XmlNodeReader-Klasse
XmlNodeReader-Member
System.Xml-Namespace