XmlTextReader.MoveToNextAttribute Metodo

Definizione

Si sposta n corrispondenza dell'attributo successivo.

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

Restituisce

true se esiste un attributo successivo; false se non esistono altri attributi.

Esempio

Nell'esempio seguente vengono visualizzati tutti gli attributi nel nodo corrente.

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

Commenti

Nota

A partire da .NET Framework 2.0, è consigliabile creare XmlReader istanze usando il XmlReader.Create metodo per sfruttare nuove funzionalità.

Se il nodo corrente è un nodo di elemento, questo metodo equivale a MoveToFirstAttribute. Se MoveToNextAttribute restituisce true, il lettore passa all'attributo successivo; in caso contrario, la posizione del lettore non cambia.

Si applica a

Vedi anche