XmlTextReader.MoveToNextAttribute Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Moves to the next attribute.
public:
override bool MoveToNextAttribute();
public override bool MoveToNextAttribute ();
override this.MoveToNextAttribute : unit -> bool
Public Overrides Function MoveToNextAttribute () As Boolean
Returns
true
if there is a next attribute; false
if there are no more attributes.
Examples
The following example displays all attributes on the current node.
public:
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
Remarks
Note
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.