XmlTextReader.MoveToNextAttribute Metoda

Definicja

Przechodzi do następnego atrybutu.

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

Zwraca

true jeśli istnieje następny atrybut; false jeśli nie ma więcej atrybutów.

Przykłady

Poniższy przykład przedstawia wszystkie atrybuty w bieżącym węźle.

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

Uwagi

Uwaga

Począwszy od .NET Framework 2.0, zalecamy utworzenie XmlReader wystąpień przy użyciu metody , aby korzystać z XmlReader.Create nowych funkcji.

Jeśli bieżący węzeł jest węzłem elementu, ta metoda jest równoważna MoveToFirstAttribute. Jeśli MoveToNextAttribute zwraca truewartość , czytnik przechodzi do następnego atrybutu; w przeciwnym razie pozycja czytnika nie zmienia się.

Dotyczy

Zobacz też