This documentation is archived and is not being maintained.

XmlTextReader.Item Property

.NET Framework 1.1

Gets the value of the attribute.

[C#] In C#, this property is the indexer for the XmlTextReader class.

Overload List

Gets the value of the attribute with the specified name.

[Visual Basic] Overloads Overrides Public Default ReadOnly Property Item(String) As String
[C#] public override string this[string] {get;}
[C++] public: __property String* get_Item(String*);
[JScript] XmlTextReader.Item (String)

Gets the value of the attribute with the specified index.

[Visual Basic] Overloads Overrides Public Default ReadOnly Property Item(Integer) As String
[C#] public override string this[int] {get;}
[C++] public: __property String* get_Item(int);
[JScript] XmlTextReader.Item (int)

Gets the value of the attribute with the specified local name and namespace URI.

[Visual Basic] Overloads Overrides Public Default ReadOnly Property Item(String, String) As String
[C#] public override string this[string, string] {get;}
[C++] public: __property String* get_Item(String*, String*);
[JScript] XmlTextReader.Item (String, String)

Example

[Visual Basic, C#, C++] The following example displays all attributes on the current node.

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of the Item property (XmlTextReader indexer). For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Public Sub DisplayAttributes(reader As XmlReader)
    If reader.HasAttributes Then
        Console.WriteLine("Attributes of <" & reader.Name & ">")
        Dim i As Integer
        For i = 0 To reader.AttributeCount - 1
            Console.WriteLine("  {0}", reader(i))
        Next i
    End If
End Sub 'DisplayAttributes

[C#] 
public void DisplayAttributes(XmlReader reader)
{
    if (reader.HasAttributes)
    {
        Console.WriteLine("Attributes of <" + reader.Name + ">");
        for (int i = 0; i < reader.AttributeCount; i++)
        {
            Console.WriteLine("  {0}", reader[i]);
        }
    }
}

[C++] 
public:
void DisplayAttributes(XmlReader* reader)
{
    if (reader->HasAttributes)
    {
        Console::WriteLine(S"Attributes of <{0}>", reader->Name);
        for (int i = 0; i < reader->AttributeCount; i++)
        {
            Console::WriteLine(S"  {0}", reader->Item[i]);
        }
    }
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

XmlTextReader Class | XmlTextReader Members | System.Xml Namespace

Show: