XmlReader.AttributeCount Свойство

Определение

При переопределении в производном классе получает количество атрибутов на текущем узле.

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

Значение свойства

Количество атрибутов на текущем узле.

Исключения

Метод XmlReader был вызван до завершения предыдущей асинхронной операции. В этом случае InvalidOperationException создается сообщение "Асинхронная операция уже выполняется".

Примеры

В следующем примере отображаются все атрибуты на текущем узле.

// 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

Комментарии

Это свойство относится только к Elementузлам. DocumentTypeXmlDeclaration (Другие типы узлов не имеют атрибутов.)

Применяется к