XmlTextReader.MoveToNextAttribute XmlTextReader.MoveToNextAttribute XmlTextReader.MoveToNextAttribute XmlTextReader.MoveToNextAttribute Method


Moves to the next attribute.

 override bool MoveToNextAttribute();
public override bool MoveToNextAttribute ();
override this.MoveToNextAttribute : unit -> bool
Public Overrides Function MoveToNextAttribute () As Boolean


true if there is a next attribute; false if there are no more attributes.


The following example displays all attributes on the current node.

   void DisplayAttributes( XmlReader^ reader )
      if ( reader->HasAttributes )
         Console::WriteLine( "Attributes of <{0}>", reader->Name );
         while ( reader->MoveToNextAttribute() )
            Console::WriteLine( " {0}={1}", reader->Name, reader->Value );
public void DisplayAttributes(XmlReader reader)
    if (reader.HasAttributes)
        Console.WriteLine("Attributes of <" + reader.Name + ">");
        while (reader.MoveToNextAttribute())
            Console.WriteLine(" {0}={1}", reader.Name, reader.Value);
Public Sub DisplayAttributes(reader As XmlReader)
    If reader.HasAttributes Then
        Console.WriteLine("Attributes of <" & reader.Name & ">")
        While reader.MoveToNextAttribute()
            Console.WriteLine(" {0}={1}", reader.Name, reader.Value)
        End While
    End If
End Sub 'DisplayAttributes



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.

If the current node is an element node, this method is equivalent to MoveToFirstAttribute. If MoveToNextAttribute returns true, the reader moves to the next attribute; otherwise, the position of the reader does not change.

Applies to

See also