如何:存取 XML 屬性 (Visual Basic)

此範例示範如何使用屬性 (Attribute) 軸屬性 (Property),依名稱存取 XML 元素中的 XML 屬性 (Attribute)。 特別是,其會使用 type 屬性 (Attribute) 軸屬性 (Property),來存取 phone 物件中名為 type 的屬性 (Attribute)。

範例

Dim phone As XElement = <phone type="home">206-555-0144</phone>

Console.WriteLine("Type: " & phone.@type)

另請參閱