XmlNamedNodeMap.Item(Int32) Methode

Definitie

Haalt het knooppunt op bij de opgegeven index in de XmlNamedNodeMap.

public:
 virtual System::Xml::XmlNode ^ Item(int index);
public virtual System.Xml.XmlNode Item(int index);
abstract member Item : int -> System.Xml.XmlNode
override this.Item : int -> System.Xml.XmlNode
Public Overridable Function Item (index As Integer) As XmlNode

Parameters

index
Int32

De indexpositie van het knooppunt dat moet worden opgehaald uit de XmlNamedNodeMap. De index is gebaseerd op nul; Daarom is de index van het eerste knooppunt 0 en is de index van het laatste knooppunt Count -1.

Retouren

De XmlNode opgegeven index. Als index de eigenschap kleiner is dan 0 of groter is dan of gelijk is aan de Count eigenschap, null wordt deze geretourneerd.

Voorbeelden

In het volgende voorbeeld wordt de XmlAttributeCollection klasse (die overgaat van XmlNamedNodeMap) gebruikt om alle kenmerken van een boek weer te geven.

using System;
using System.IO;
using System.Xml;

public class Sample
{
  public static void Main()
  {
     XmlDocument doc = new XmlDocument();
     doc.LoadXml("<book genre='novel' publicationdate='1997'> " +
                 "  <title>Pride And Prejudice</title>" +
                 "</book>");

     XmlAttributeCollection attrColl = doc.DocumentElement.Attributes;

     Console.WriteLine("Display all the attributes for this book...");
     for (int i=0; i < attrColl.Count; i++)
     {
        Console.WriteLine("{0} = {1}", attrColl.Item(i).Name, attrColl.Item(i).Value);
     }
  }
}
Imports System.IO
Imports System.Xml

public class Sample

  public shared sub Main()

    Dim doc as XmlDocument = new XmlDocument()
    doc.LoadXml("<book genre='novel' publicationdate='1997'> " & _
                "  <title>Pride And Prejudice</title>" & _
                "</book>")
                         
    Dim attrColl as XmlAttributeCollection = doc.DocumentElement.Attributes

    Console.WriteLine("Display all the attributes for this book...")
    Dim i As Integer
    For i = 0 To attrColl.Count - 1
       Console.WriteLine("{0} = {1}", attrColl.Item(i).Name,attrColl.Item(i).Value)
    Next
    
  end sub
end class

Van toepassing op