XmlNamedNodeMap.GetEnumerator 메서드

정의

XmlNamedNodeMap의 노드 컬렉션에 대한 "foreach" 스타일 반복 지원을 제공합니다.Provides support for the "foreach" style iteration over the collection of nodes in the XmlNamedNodeMap.

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

반환

IEnumerator

열거자 개체입니다.An enumerator object.

구현

예제

다음 예제에서는 컬렉션의 모든 특성을 표시 합니다.The following example displays all attributes in the collection.

#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

적용 대상