XmlAttributeCollection.ItemOf Property (Int32)


Gets the attribute with the specified index.

Namespace:   System.Xml
Assembly:  System.Xml (in System.Xml.dll)

public XmlAttribute this[
	int i
] { get; }


Type: System.Int32

The index of the attribute.

Property Value

Type: System.Xml.XmlAttribute

The XmlAttribute at the specified index.

Exception Condition

The index being passed in is out of range.

This property is a Microsoft extension to the Document Object Model (DOM). It is equivalent to calling XmlNamedNodeMap.Item.

The following example displays all the attributes in the collection.

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

public class Sample
  public static void Main(){

    XmlDocument doc = new XmlDocument();
    doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" +
                "<title>Pride And Prejudice</title>" +

    //Create an attribute collection. 
    XmlAttributeCollection attrColl = doc.DocumentElement.Attributes;

    Console.WriteLine("Display all the attributes in the collection...\r\n");
    for (int i=0; i < attrColl.Count; i++)
      Console.Write("{0} = ", attrColl[i].Name);
      Console.Write("{0}", attrColl[i].Value);

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Return to top