IXmlNodeSelector.SelectSingleNodeNS(String, Object) 方法

定义

将指定的模式匹配操作应用于此节点的上下文,并返回第一个匹配的节点。

public:
 IXmlNode ^ SelectSingleNodeNS(Platform::String ^ xpath, Platform::Object ^ namespaces);
IXmlNode SelectSingleNodeNS(winrt::hstring const& xpath, IInspectable const& namespaces);
public IXmlNode SelectSingleNodeNS(string xpath, object namespaces);
function selectSingleNodeNS(xpath, namespaces)
Public Function SelectSingleNodeNS (xpath As String, namespaces As Object) As IXmlNode

参数

xpath
String

Platform::String

winrt::hstring

指定 XPath 表达式。

namespaces
Object

Platform::Object

IInspectable

包含一个字符串,该字符串指定当需要在外部定义新命名空间时要在 XPath 表达式中使用的命名空间。 命名空间以 XML 样式定义为命名空间声明属性的空格分隔列表。 也可以使用此属性来设置默认命名空间。

返回

与给定模式匹配操作匹配的第一个节点。 如果没有与表达式匹配的节点,此方法将返回 null 值。

示例

var input = node.SelectSingleNodeNS("//*[@x:Name='Input']", "xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'");
auto input = node.SelectSingleNodeNS(L"//*[@x:Name='Input']", winrt::box_value(L"xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'"));

注解

查询中的前缀是使用指定的命名空间声明解析的。

适用于