XAttribute.NextAttribute Propiedad

Definición

Obtiene el siguiente atributo del elemento primario.

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

Valor de propiedad

que XAttribute contiene el siguiente atributo del elemento primario.

Ejemplos

En el ejemplo siguiente se muestra cómo recorrer en iteración los atributos de un elemento mediante esta propiedad.

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

Este ejemplo produce el siguiente resultado:

Att1="1"
Att2="2"
Att3="3"
Att4="4"

Comentarios

Los atributos se mantienen en el árbol XML en el orden en que se agregaron al elemento . Cuando devuelve Attributesuna colección de atributos, se devuelven en el orden en que se agregaron y no se ordenan. Cuando se solicita el siguiente atributo a través de esta propiedad, esta propiedad devuelve el atributo que se agregó después de este atributo.

Si este atributo no tiene un elemento primario o si no hay ningún atributo siguiente, esta propiedad devuelve null.

Se aplica a

Consulte también