XmlNamedNodeMap.GetEnumerator Methode
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Stellt Unterstützung für "foreach"-Iterationen in der Auflistung von Knoten in der XmlNamedNodeMap
bereit.
public:
virtual System::Collections::IEnumerator ^ GetEnumerator();
public virtual System.Collections.IEnumerator GetEnumerator ();
abstract member GetEnumerator : unit -> System.Collections.IEnumerator
override this.GetEnumerator : unit -> System.Collections.IEnumerator
Public Overridable Function GetEnumerator () As IEnumerator
Ein Enumeratorobjekt.
Im folgenden Beispiel werden alle Attribute in der Auflistung angezeigt.
#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->LoadXml( "<book genre='novel' publicationdate='1997' "
" ISBN='1-861001-57-5'>"
" <title>Pride And Prejudice</title>"
"</book>" );
XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes;
Console::WriteLine( "Display all the attributes for this book..." );
IEnumerator^ ienum = attrColl->GetEnumerator();
while ( ienum->MoveNext() )
{
XmlAttribute^ attr = dynamic_cast<XmlAttribute^>(ienum->Current);
Console::WriteLine( "{0} = {1}", attr->Name, attr->Value );
}
}
using System;
using System.IO;
using System.Xml;
using System.Collections;
public class Sample
{
public static void Main()
{
XmlDocument doc = new XmlDocument();
doc.LoadXml("<book genre='novel' publicationdate='1997' " +
" ISBN='1-861001-57-5'>" +
" <title>Pride And Prejudice</title>" +
"</book>");
XmlAttributeCollection attrColl = doc.DocumentElement.Attributes;
Console.WriteLine("Display all the attributes for this book...");
IEnumerator ienum = attrColl.GetEnumerator();
while (ienum.MoveNext())
{
XmlAttribute attr = (XmlAttribute)ienum.Current;
Console.WriteLine("{0} = {1}", attr.Name, attr.Value);
}
}
}
Option Explicit
Option Strict
Imports System.IO
Imports System.Xml
Imports System.Collections
public class Sample
public shared sub Main()
Dim doc as XmlDocument = new XmlDocument()
doc.LoadXml("<book genre='novel' publicationdate='1997' " & _
" ISBN='1-861001-57-5'>" & _
" <title>Pride And Prejudice</title>" & _
"</book>")
Dim attrColl as XmlAttributeCollection = doc.DocumentElement.Attributes
Console.WriteLine("Display all the attributes for this book...")
Dim ienum as IEnumerator = attrColl.GetEnumerator()
Dim attr as XmlAttribute
while (ienum.MoveNext())
attr = CType(ienum.Current, XmlAttribute)
Console.WriteLine("{0} = {1}", attr.Name, attr.Value)
end while
end sub
end class
Produkt | Versionen |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 |
.NET Standard | 2.0, 2.1 |
UWP | 10.0 |