Binding.XPath 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置一个 XPath 查询,该查询返回要使用的 XML 绑定源上的值。
public:
property System::String ^ XPath { System::String ^ get(); void set(System::String ^ value); };
public string XPath { get; set; }
member this.XPath : string with get, set
Public Property XPath As String
属性值
XPath 查询。 默认值为 null。
注解
当绑定源是 XML 数据而不是公共语言运行时 (CLR) 对象时,将使用该 XPath 属性而不是 Path 属性来指示要使用的绑定源上的值的路径。
通过设置 XPath 属性,你将创建一个 XPath 查询来选择节点或节点集合 (System.Xml.XmlElement ,两 System.Xml.XmlAttribute 者都派生自 System.Xml.XmlNode) 。 System.Xml.XmlNode 是一个公共语言运行时 (CLR) 对象,这意味着可以使用该 Path 属性绑定到其属性。
该方法 XmlNode.SelectNodes 处理 XPath 属性中的 XPath 表达式。 XPath 不支持函数。 有关 XPath 表达式信息,请参阅 SelectNodes 示例部分中提供的文档和一些示例。
LINQ to XML 对象 XDocument , XElement 不使用 XPath。 有关详细信息,请参阅 如何:绑定到 XDocument、XElement 或 LINQ for XML 查询结果。