Binding.XPath 属性

定义

获取或设置 XPath 查询,该查询返回要使用的 XMLXML 绑定源上的值。Gets or sets an XPath query that returns the value on the XMLXML binding source to use.

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 查询。The XPath query. 默认值为 nullThe default is null.

注解

当绑定源 XMLXML 数据而不是 公共语言运行时 (CLR)common language runtime (CLR) 对象时,将使用 XPath 属性,而不是 Path 属性来指示要使用的绑定源上的值的路径。When the binding source is XMLXML data instead of a 公共语言运行时 (CLR)common language runtime (CLR) object, the XPath property is used instead of the Path property to indicate the path to the value on the binding source to use.

通过设置 XPath 属性,你将创建一个 XPath 查询来选择节点或节点集合(System.Xml.XmlElementSystem.Xml.XmlAttribute 均派生自 System.Xml.XmlNode)。By setting the XPath property, you are creating an XPath query to select a node or a collection of nodes (System.Xml.XmlElement and System.Xml.XmlAttribute both derive from System.Xml.XmlNode). System.Xml.XmlNode公共语言运行时 (CLR)common language runtime (CLR) 对象,这意味着可以使用 Path 属性绑定到其属性。System.Xml.XmlNode is a 公共语言运行时 (CLR)common language runtime (CLR) object, which means you can bind to its properties using the Path property.

XmlNode.SelectNodes 方法处理 XPath 属性中的 XPath 表达式。The XmlNode.SelectNodes method handles the XPath expressions from the XPath property. XPath 函数不受支持。XPath functions are not supported. 有关 XPath 表达式的信息,请参阅 "示例" 部分中提供的 SelectNodes 文档和一些示例。For XPath expression information, see the SelectNodes documentation and some examples provided in the Example section.

LINQ to XML 对象 XDocument 并且 XElement 不使用 XPathLINQ to XML objects XDocument and XElement do not use XPath. 有关详细信息,请参阅如何:绑定到 XDocument、system.xml.linq.xelement> 或 LINQ FOR XML 查询结果For details, see How to: Bind to XDocument, XElement, or LINQ for XML Query Results.

适用于