XmlDataSource with XPath - can I get the raw data in code?
If an ASP.NET form has an XmlDataSource on it, and in code I am setting the X开发者_运维知识库Path 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?
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 theData
property or in the file identified by theDataFile
property, with any transformations andXPath
queries applied.
精彩评论