XmlReader.AttributeCount Właściwość

Definicja

Po zastąpieniu w klasie pochodnej pobiera liczbę atrybutów w bieżącym węźle.

public:
 abstract property int AttributeCount { int get(); };
public abstract int AttributeCount { get; }
member this.AttributeCount : int
Public MustOverride ReadOnly Property AttributeCount As Integer

Wartość właściwości

Liczba atrybutów w bieżącym węźle.

Wyjątki

Metoda XmlReader została wywołana przed zakończeniem poprzedniej operacji asynchronicznej. W takim 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.

// Display all attributes.
if (reader.HasAttributes) {
  Console.WriteLine("Attributes of <" + reader.Name + ">");
  for (int i = 0; i < reader.AttributeCount; i++) {
    Console.WriteLine("  {0}", reader[i]);
  }
  // Move the reader back to the element node.
  reader.MoveToElement();
}
' Display all attributes.
If reader.HasAttributes Then
  Console.WriteLine("Attributes of <" + reader.Name + ">")
  Dim i As Integer
  For i = 0 To (reader.AttributeCount - 1)
    Console.WriteLine("  {0}", reader(i))
  Next i
  ' Move the reader back to the element node.
  reader.MoveToElement() 
End If

Uwagi

Ta właściwość jest odpowiednia tylko dla Elementwęzłów i DocumentTypeXmlDeclaration . (Inne typy węzłów nie mają atrybutów).

Dotyczy