XAttribute.NextAttribute 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 l’attribut suivant de l’élément parent.
public:
property System::Xml::Linq::XAttribute ^ NextAttribute { System::Xml::Linq::XAttribute ^ get(); };
public System.Xml.Linq.XAttribute NextAttribute { get; }
public System.Xml.Linq.XAttribute? NextAttribute { get; }
member this.NextAttribute : System.Xml.Linq.XAttribute
Public ReadOnly Property NextAttribute As XAttribute
Valeur de propriété
Contenant XAttribute l’attribut suivant de l’élément parent.
Exemples
L’exemple suivant montre comment itérer dans les attributs d’un élément à l’aide de cette propriété.
XElement root = new XElement("Root",
new XAttribute("Att1", 1),
new XAttribute("Att2", 2),
new XAttribute("Att3", 3),
new XAttribute("Att4", 4)
);
XAttribute att = root.FirstAttribute;
do {
Console.WriteLine(att);
}
while((att = att.NextAttribute) != null);
Dim root As XElement = <Root Att1="1" Att2="2" Att3="3" Att4="4"/>
Dim att As XAttribute = root.FirstAttribute
Dim val As Boolean = True
Do
Console.WriteLine(att)
att = att.NextAttribute
Loop While (Not (att Is Nothing))
Cet exemple produit la sortie suivante :
Att1="1"
Att2="2"
Att3="3"
Att4="4"
Remarques
Les attributs sont conservés dans l’arborescence XML dans l’ordre dans lequel ils ont été ajoutés à l’élément. Lorsqu’une collection d’attributs est retournée par Attributes, elles sont retournées dans l’ordre dans lequel elles ont été ajoutées et ne sont pas triées. Lorsque vous demandez l’attribut suivant via cette propriété, cette propriété retourne l’attribut qui a été ajouté après cet attribut.
Si cet attribut n’a pas de parent ou s’il n’y a pas d’attribut suivant, cette propriété retourne null.