XmlNodeList.ItemOf[Int32] Özellik

Tanım

Belirtilen dizinde bir düğüm alır.

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

Parametreler

i
Int32

Düğüm listesinde sıfır tabanlı dizin.

Özellik Değeri

XmlNode

XmlNode koleksiyonda belirtilen dizine sahip. Dizin listedeki düğüm sayısından büyük veya buna eşitse, bu döndürür null.

Örnekler

Aşağıdaki örnek bir XmlDocument nesnesi oluşturur ve tüm kitap başlıklarını görüntülemek için yöntemini ve sonucunu XmlNodeList kullanırGetElementsByTagName.

#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

Örnek, giriş olarak dosyasını 2books.xml kullanır.

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

Şunlara uygulanır