XmlTextReader.MoveToNextAttribute Método

Definição

Passa para o atributo seguinte.

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

Devoluções

true se existir um atributo seguinte; false se não houver mais atributos.

Exemplos

O exemplo seguinte mostra todos os atributos do nó atual.

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

Observações

Note

Recomendamos que crie instâncias XmlReader usando o método XmlReader.Create para aproveitar a nova funcionalidade.

Se o nó atual for um nó elemento, este método é equivalente a MoveToFirstAttribute. Se MoveToNextAttribute devolver true, o leitor passa para o atributo seguinte; caso contrário, a posição do leitor não muda.

Aplica-se a

Ver também