語言

XPathNavigator.Compile(String) 方法

定義

編譯代表 XPath 運算式的字串並回傳物件 XPathExpression 。

public:
 virtual System::Xml::XPath::XPathExpression ^ Compile(System::String ^ xpath);
public virtual System.Xml.XPath.XPathExpression Compile(string xpath);
abstract member Compile : string -> System.Xml.XPath.XPathExpression
override this.Compile : string -> System.Xml.XPath.XPathExpression
Public Overridable Function Compile (xpath As String) As XPathExpression

參數

xpath
String

一個代表 XPath 表達式的字串。

傳回

一個 XPathExpression 代表 XPath 表達式的物件。

例外狀況

該 xpath 參數包含一個不有效的 XPath 表達式。

XPath 表達式無效。

備註

XPath 表達式會被評估以產生以下其中一種回傳類型:

  • 節點集合:一組無重複節點的無序節點集合

  • 布林值: true 或 false

  • 數字:浮點數

  • 字串:一連串 UCS 字元

回傳節點集的表達式可用於 Select and Evaluate 方法中。 可使用 Evaluate 回傳布林值、數字或字串的表達式。 該方法有效表達 Matches 式的規則是該方法專屬的。

適用於