views:

74

answers:

1

If an ASP.NET form has an XmlDataSource on it, and in code I am setting the XPath filter, e.g:

xmlExample.XPath = 
     String.Format("data/reasons/reason[@text='{0}']/details/",someValue);

... can I then get the result of that XPath filtering in code, or do I have to bind to a control to find out the results?

In other words, is it possible to use code to access the xml data that an XmlDataSource is going to return?

A: 

I haven't actually tried it, but the documentation for XmlDataSource.GetXmlDocument (new with .NET 2.0) suggests it will do exactly what you want:

Return Value

An XmlDataDocument that represents the XML specified in the Data property or in the file identified by the DataFile property, with any transformations and XPath queries applied.

AakashM
That returns the original XML document, but doesn't seem to apply the XPath filter to it (if one is specified)
codeulike