Share via


在 Visual Basic 中存取 XML

更新:2007 年 11 月

Visual Basic 提供 XML 軸屬性以存取及巡覽 LINQ to XML 結構。這些屬性使用特殊語法,可讓您經由指定 XML 名稱,存取項目和屬性 (Attribute)。

下表列出可以讓您存取 Visual Basic 中 XML 項目和屬性的語言功能。

XML Axis 屬性

屬性說明

範例

說明

子項軸屬性

contact.<phone>

取得所有 phone 項目,這些項目是 contact 項目的子項目。

屬性軸屬性 (Attribute Axis)

phone.@type

取得 phone 項目的所有 type 屬性 (Attribute)。

子代軸屬性 (Descendant Axis)

contacts...<name>

取得 contacts 項目的所有 name 項目,無論其出現在多深的階層架構中。

擴充索引子屬性 (Extension Indexer)

contacts...<name>(0)

取得序列中的第一個 name 項目。

值屬性 (Value)

contacts...<name>.Value

取得序列中第一個物件的字串表示,如果序列是空的則為 Nothing。

在本節中

相關章節