XPathBinder Class
Provides support for rapid application development (RAD) designers to parse data-binding expressions that use XPath expressions. This class cannot be inherited.
Assembly: System.Web (in System.Web.dll)
The XPathBinder type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() ![]() | Eval(Object, String) | Evaluates XPath data-binding expressions at run time. |
![]() ![]() | Eval(Object, String, String) | Evaluates XPath data-binding expressions at run time and formats the result as text to be displayed in the requesting browser. |
![]() ![]() | Eval(Object, String, IXmlNamespaceResolver) | Evaluates XPath data-binding expressions at run time and formats the result as text to be displayed in the requesting browser, using the IXmlNamespaceResolver object specified to resolve namespace prefixes in the XPath expression. |
![]() ![]() | Eval(Object, String, String, IXmlNamespaceResolver) | Evaluates XPath data-binding expressions at run time and formats the result as text to be displayed in the requesting browser, using the IXmlNamespaceResolver object specified to resolve namespace prefixes in the XPath expression.. |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() ![]() | Select(Object, String) | Uses an XPath data-binding expression at run time to return a list of nodes. |
![]() ![]() | Select(Object, String, IXmlNamespaceResolver) | Uses an XPath data-binding expression at run time to return a list of nodes, using the IXmlNamespaceResolver object specified to resolve namespace prefixes in the XPath expression. |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
You can use the overloaded Eval method of this class to bind to the result of an XPath expression executed against an object that implements the IXPathNavigable interface, such as an XmlNode. You can use the Select method to retrieve the results of an XPath expression executed against an IXPathNavigable object as an IEnumerable list of nodes. This list of nodes can be enumerated directly or assigned to the DataSource property of a list control, such as a Repeater or DataList.
You can use a simplified version of data-binding syntax when using the XPathBinder methods declaratively. Instead of calling XPathBinder.Eval(Container.DataItem, xpath) you can use XPath(xpath). Similarly, instead of calling XPathBinder.Select(Container.DataItem, xpath), you can use XPathSelect(xpath) to retrieve an IEnumerable set of nodes. When using this simplified syntax, the Eval and Select methods assume a default Container.DataItem context object.
For more information about data binding to ASP.NET server controls, see Data-Binding Expression Syntax.
The following code example demonstrates how to use an XmlDataSource control with a templated Repeater control to display XML data. This example has two parts:
A Web Forms page that displays XML data.
An XML file that contains the data.
The first part of the example shows a Web Forms page that displays XML data accessed through an XmlDataSource control. A Repeater control uses simplified Eval(Object, String) method syntax to bind to data items within the XML document that the XmlDataSource represents. It uses the Select(Object, String) method to retrieve an IEnumerable list and assign it as a late-bound DataSource property for the Repeater control.
The second example provides the XML file, Order.xml, that is used as the source of the data displayed in the Web Forms page defined above.
<?xml version="1.0" encoding="iso-8859-1"?>
<orders>
<order>
<customer id="12345" />
<customername>
<firstn>John</firstn>
<lastn>Doe</lastn>
</customername>
<transaction id="12345" />
<shipaddress>
<address1>1234 Tenth Avenue</address1>
<city>Bellevue</city>
<state>Washington</state>
<zip>98001</zip>
</shipaddress>
<summary>
<item dept="tools">screwdriver</item>
<item dept="tools">hammer</item>
<item dept="plumbing">fixture</item>
</summary>
</order>
</orders>
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.


