XAttribute.NextAttribute プロパティ
定義
親要素の次の属性を取得します。Gets the next attribute of the parent element.
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
プロパティ値
親要素の次の属性を格納している XAttribute。An XAttribute containing the next attribute of the parent element.
例
次の例は、このプロパティを使用して要素の属性を反復処理する方法を示しています。The following example shows how to iterate through the attributes of an element using this property.
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))
この例を実行すると、次の出力が生成されます。This example produces the following output:
Att1="1"
Att2="2"
Att3="3"
Att4="4"
注釈
属性は、要素に追加された順序で XML ツリーに保持されます。Attributes are maintained in the XML tree in the order that they were added to the element. によって返された属性のコレクションは Attributes 、追加された順序で返され、並べ替えられません。When a collection of attributes is returned by Attributes, they are returned in the order that they were added, and are not sorted. このプロパティを使用して次の属性を要求すると、このプロパティは、この属性の後に追加された属性を返します。When you request the next attribute through this property, this property returns the attribute that was added after this attribute.
この属性に親がない場合、または次の属性が存在しない場合、このプロパティはを返し null
ます。If this attribute does not have a parent, or if there is no next attribute, then this property returns null
.