Export (0) Print
Expand All

XmlTextReader.MoveToAttribute Method (Int32)

Moves to the attribute with the specified index.

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

'Declaration
Public Overrides Sub MoveToAttribute ( _
	i As Integer _
)

Parameters

i
Type: System.Int32

The index of the attribute.

ExceptionCondition
ArgumentOutOfRangeException

The i parameter is less than 0 or greater than or equal to AttributeCount.

NoteNote

Starting with the .NET Framework 2.0, we recommend that you create XmlReader instances by using the XmlReader.Create method to take advantage of new functionality.

The following example displays all attributes on the current node.

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
            reader.MoveToAttribute(i)
            Console.Write(" {0}={1}", reader.Name, reader.Value)
        Next i
        reader.MoveToElement() 'Moves the reader back to the element node.
    End If 
End Sub 'DisplayAttributes

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0
Show:
© 2015 Microsoft