I have this simple XML:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<DocumentElement>
<Schedule>
<CATEGORY>FAMILY</CATEGORY>
<LOCATIONS>119</LOCATIONS>
</Schedule>
<Schedule>
<CATEGORY>ADULTS</CATEGORY>
<LOCATIONS>314</LOCATIONS>
</Schedule>
</DocumentElement>
</xml>
I am binding it to a GridView through a XmlDataSource. I need to select elements having Category=Family. I set XmlDataSource.XPath to these expressions but they return no results:
/DocumentElement/Schedule[CATEGORY = 'FAMILY']
/DocumentElement/Schedule/CATEGORY[. = 'FAMILY']
What am I doing wrong? Do you know of useful documentation with examples? I really tried to find one but could not. Really appreciate the help.
Your xml should not be enclosed in an xml element. Remove the
</xml>from the end.With that you should have valid xml and this should select the Schedule element with a category element whose value = Family:
A good source of examples can be found here: http://msdn.microsoft.com/en-us/library/ms256086.aspx