XmlTextReader.AttributeCount Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient le nombre d’attributs sur le nœud actuel.
public:
virtual property int AttributeCount { int get(); };
public override int AttributeCount { get; }
member this.AttributeCount : int
Public Overrides ReadOnly Property AttributeCount As Integer
Valeur de propriété
Nombre d’attributs sur le nœud actuel.
Exemples
L’exemple suivant affiche tous les attributs sur le nœud actuel.
public void DisplayAttributes(XmlReader reader)
{
if (reader.HasAttributes)
{
Console.WriteLine("Attributes of <" + reader.Name + ">");
for (int i = 0; i < reader.AttributeCount; i++)
{
reader.MoveToAttribute(i);
Console.Write(" {0}={1}", reader.Name, reader.Value);
}
reader.MoveToElement(); //Moves the reader back to the element node.
}
}
Public Sub DisplayAttributes(reader As XmlReader)
If reader.HasAttributes Then
Console.WriteLine("Attributes of <" & reader.Name & ">")
Dim i As Integer
For i = 0 To reader.AttributeCount - 1
reader.MoveToAttribute(i)
Console.Write(" {0}={1}", reader.Name, reader.Value)
Next i
reader.MoveToElement() 'Moves the reader back to the element node.
End If
End Sub
Remarques
Note
Nous vous recommandons de créer des instances XmlReader à l’aide de la méthode XmlReader.Create pour tirer parti de nouvelles fonctionnalités.
Cette propriété s’applique uniquement aux ElementDocumentType nœuds.XmlDeclaration (Les autres types de nœuds n’ont pas d’attributs.)