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.
Stellt eine einfache for each-Iteration der Auflistung von Knoten in der XmlNodeList bereit.
Namespace: System.Xml
Assembly: System.Xml (in system.xml.dll)
Syntax
'Declaration
Public MustOverride Function GetEnumerator As IEnumerator
'Usage
Dim instance As XmlNodeList
Dim returnValue As IEnumerator
returnValue = instance.GetEnumerator
public abstract IEnumerator GetEnumerator ()
public:
virtual IEnumerator^ GetEnumerator () abstract
public abstract IEnumerator GetEnumerator ()
public abstract function GetEnumerator () : IEnumerator
Rückgabewert
Ein IEnumerator.
Beispiel
Im folgenden Beispiel werden alle Buchtitel angezeigt.
Imports System
Imports System.IO
Imports System.Xml
Imports System.Collections
public class Sample
public shared sub Main()
Dim doc as XmlDocument = new XmlDocument()
doc.Load("2books.xml")
'Get and display all the book titles.
Dim root as XmlElement = doc.DocumentElement
Dim elemList as XmlNodeList = root.GetElementsByTagName("title")
Dim ienum as IEnumerator = elemList.GetEnumerator()
while (ienum.MoveNext())
Dim title as XmlNode
title = CType(ienum.Current, XmlNode)
Console.WriteLine(title.InnerText)
end while
end sub
end class
using System;
using System.IO;
using System.Xml;
using System.Collections;
public class Sample {
public static void Main() {
XmlDocument doc = new XmlDocument();
doc.Load("2books.xml");
//Get and display all the book titles.
XmlElement root = doc.DocumentElement;
XmlNodeList elemList = root.GetElementsByTagName("title");
IEnumerator ienum = elemList.GetEnumerator();
while (ienum.MoveNext()) {
XmlNode title = (XmlNode) ienum.Current;
Console.WriteLine(title.InnerText);
}
}
}
#using <System.Xml.dll>
using namespace System;
using namespace System::IO;
using namespace System::Xml;
using namespace System::Collections;
int main()
{
XmlDocument^ doc = gcnew XmlDocument;
doc->Load( "2books.xml" );
//Get and display all the book titles.
XmlElement^ root = doc->DocumentElement;
XmlNodeList^ elemList = root->GetElementsByTagName( "title" );
IEnumerator^ ienum = elemList->GetEnumerator();
while ( ienum->MoveNext() )
{
XmlNode^ title = dynamic_cast<XmlNode^>(ienum->Current);
Console::WriteLine( title->InnerText );
}
}
import System.*;
import System.IO.*;
import System.Xml.*;
import System.Collections.*;
public class Sample
{
public static void main(String[] args)
{
XmlDocument doc = new XmlDocument();
doc.Load("2books.xml");
//Get and display all the book titles.
XmlElement root = doc.get_DocumentElement();
XmlNodeList elemList = root.GetElementsByTagName("title");
IEnumerator iEnum = elemList.GetEnumerator();
while (iEnum.MoveNext()) {
XmlNode title = (XmlNode)iEnum.get_Current();
Console.WriteLine(title.get_InnerText());
}
} //main
} //Sample
Im Beispiel wird die Datei 2books.xml als Eingabe verwendet.
<!--sample XML fragment-->
<bookstore>
<book genre='novel' ISBN='10-861003-324'>
<title>The Handmaid's Tale</title>
<price>19.95</price>
</book>
<book genre='novel' ISBN='1-861001-57-5'>
<title>Pride And Prejudice</title>
<price>24.95</price>
</book>
</bookstore>
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