如何:访问 XML 属性 (Visual Basic)

更新:2007 年 11 月

此示例演示如何使用属性 (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)

请参见

参考

XML 属性 (Attribute) 轴属性 (Property)

XElement.Attributes

其他资源

在 Visual Basic 中访问 XML

Visual Basic 中的 XML