XmlAttributeCollection::ItemOf Property (Int32)

 

Gets the attribute with the specified index.

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

public:
property XmlAttribute^ default[
	int i
] {
	XmlAttribute^ get(int i);
}

Parameters

i
Type: System::Int32

The index of the attribute.

Property Value

Type: System.Xml::XmlAttribute^

The XmlAttribute at the specified index.

Exception Condition
IndexOutOfRangeException

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.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   XmlDocument^ doc = gcnew XmlDocument;
   doc->LoadXml( "<book genre='novel' ISBN='1-861001-57-5'><title>Pride And Prejudice</title></book>" );

   //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 );
      Console::WriteLine();

   }
}

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