XmlDataSource::XPath Property
Assembly: System.Web (in System.Web.dll)
<asp:XmlDataSource XPath="String" />
Property Value
Type: System::StringA string that represents an XPath expression that can be used to filter the data contained by the Data property or by the XML file indicated by the DataFile property. The default value is String::Empty.
| Exception | Condition |
|---|---|
| InvalidOperationException | The document is loading. |
For more information on XPath data-binding expressions, see Binding a Tabular Control to the XmlDataSource Control.
| Topic | Location |
|---|---|
| Walkthrough: Creating a Web Page to Display XML Data | Building ASP .NET Web Applications in Visual Studio |
| Walkthrough: Displaying an XML Document in a Web Forms Page Using Transformations | Building ASP .NET Web Applications in Visual Studio |
The following code example demonstrates how to use an XmlDataSource control with a templated Repeater control to display XML data that has been filtered using an XPath expression. In this example, XPath syntax is used to filter the XML data when the XPath property of the data source control is set, and also binds elements of the Repeater control template to the XML data.
The XML file in the code example has the following data:
<bookstore>
<genre name="fiction">
<book ISBN="0000000000">
<title>Secrets of Silicon Valley</title>
<price>12.95</price>
<chapters>
<chapter num="1" name="Introduction" />
<chapter num="2" name="Body" />
<chapter num="3" name="Conclusion" />
</chapters>
</book>
</genre>
<genre name="novel">
<book genre="novel" ISBN="1111111111">
<title>Straight Talk About Computers</title>
<price>24.95</price>
<chapters>
<chapter num="1" name="Introduction" />
<chapter num="2" name="Body" />
<chapter num="3" name="Conclusion" />
</chapters>
</book>
</genre>
</bookstore>
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.