XmlReader.HasAttributes Właściwość

Definicja

Pobiera wartość wskazującą, czy bieżący węzeł ma jakiekolwiek atrybuty.

public:
 virtual property bool HasAttributes { bool get(); };
public virtual bool HasAttributes { get; }
member this.HasAttributes : bool
Public Overridable ReadOnly Property HasAttributes As Boolean

Wartość właściwości

Boolean

true jeśli bieżący węzeł ma atrybuty; w przeciwnym razie , false.

Wyjątki

Metoda XmlReader została wywołana przed zakończeniem poprzedniej operacji asynchronicznej. W tym przypadku InvalidOperationException jest zgłaszany komunikat "Operacja asynchroniczna jest już w toku".

Przykłady

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

if (reader.HasAttributes) {
  Console.WriteLine("Attributes of <" + reader.Name + ">");
  while (reader.MoveToNextAttribute()) {
    Console.WriteLine(" {0}={1}", reader.Name, reader.Value);
  }
  // Move the reader back to the element node.
  reader.MoveToElement();
}
If reader.HasAttributes Then
  Console.WriteLine("Attributes of <" + reader.Name + ">")
  While reader.MoveToNextAttribute()
    Console.WriteLine(" {0}={1}", reader.Name, reader.Value)
  End While
  ' Move the reader back to the element node.
  reader.MoveToElement()
End If

Dotyczy