XmlNodeList.ItemOf[Int32] 속성

정의

특정 인덱스에서 노드를 가져옵니다.

public:
 virtual property System::Xml::XmlNode ^ default[int] { System::Xml::XmlNode ^ get(int i); };
public virtual System.Xml.XmlNode this[int i] { get; }
public virtual System.Xml.XmlNode? this[int i] { get; }
member this.ItemOf(int) : System.Xml.XmlNode
Default Public Overridable ReadOnly Property ItemOf(i As Integer) As XmlNode

매개 변수

i
Int32

노드 목록에 대한 0부터 시작하는 인덱스입니다.

속성 값

XmlNode

컬렉션에서 지정된 인덱스의 XmlNode입니다. 인덱스가 목록의 노드 수보다 크거나 같은 경우 null을 반환합니다.

예제

다음 예제에서는 개체를 XmlDocument 만들고 메서드와 결과를 XmlNodeList 사용하여 GetElementsByTagName 모든 책 제목을 표시합니다.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;

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" );
   for ( int i = 0; i < elemList->Count; i++ )
   {
      Console::WriteLine( elemList[ i ]->InnerXml );
   }
}
using System;
using System.IO;
using System.Xml;

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");
     for (int i=0; i < elemList.Count; i++)
     {
        Console.WriteLine(elemList[i].InnerXml);
     }
  }
}
Imports System.IO
Imports System.Xml

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 i as integer
     for i=0  to elemList.Count-1
        Console.WriteLine(elemList.ItemOf(i).InnerXml)
     next
    
  end sub
end class

이 예제에서는 파일을 2books.xml 입력으로 사용합니다.

<!--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>

적용 대상