This documentation is archived and is not being maintained.

XmlTextReader.MoveToNextAttribute Method

Moves to the next attribute.

[Visual Basic]
Overrides Public Function MoveToNextAttribute() As Boolean
[C#]
public override bool MoveToNextAttribute();
[C++]
public: bool MoveToNextAttribute();
[JScript]
public override function MoveToNextAttribute() : Boolean;

Return Value

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

Remarks

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.

Example

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

[Visual Basic] 
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

[C#] 
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);
        }
    }
}

[C++] 
public:
    void DisplayAttributes(XmlReader* reader)
    {
        if (reader->HasAttributes)
        {
            Console::WriteLine(S"Attributes of <{0}>", reader->Name);
            while (reader->MoveToNextAttribute())
            {
                Console::WriteLine(S" {0}={1}", reader->Name, reader->Value);
            }
        }
    }

[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.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

XmlTextReader Class | XmlTextReader Members | System.Xml Namespace

Show: