XmlReader.HasAttributes Vlastnost

Definice

Získá hodnotu určující, zda aktuální uzel má nějaké atributy.

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

Hodnota vlastnosti

truepokud má aktuální uzel atributy; v opačném případě . false

Výjimky

Před XmlReader dokončením předchozí asynchronní operace byla volána metoda. V tomto případě InvalidOperationException je vyvolán zpráva "Asynchronní operace už probíhá".

Příklady

Následující příklad zobrazí všechny atributy na aktuálním uzlu.

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

Platí pro