I have a TreeView bound to an XmlDataSource which uses a large XML file. This all works well.
What I would like to do is to allow the user to select a particular node (in some way - which I can deal with) and then somehow rebind the TreeView so that it only shows that node and its children. I do not want to have to generate a new XML data file -
so I would expect that there is a way to get the XmlDataSource to 'start' from a particular node. Has anyone done this? I have a feeling that it might involve XPath, but I have little or no understanding of that so would need some advice.
Obviously I need to describe my specific scenario more clearly.
Each XML element has the same name 'term' (this is a hierarchy of similar things) and 2 attributes: ID and Name. Both attribute values will be unique. What I want is to select the element with ID={aspecified value} and all its children. Presumably this will
have to be done using XPath but I have read numerous tutorials and cannot find an example that helps in my case. Any help gratefully received.
Member
6 Points
171 Posts
XmlDataSource - how to specify root node
Mar 09, 2013 05:18 AM|jstranger|LINK
I have a TreeView bound to an XmlDataSource which uses a large XML file. This all works well.
What I would like to do is to allow the user to select a particular node (in some way - which I can deal with) and then somehow rebind the TreeView so that it only shows that node and its children. I do not want to have to generate a new XML data file - so I would expect that there is a way to get the XmlDataSource to 'start' from a particular node. Has anyone done this? I have a feeling that it might involve XPath, but I have little or no understanding of that so would need some advice.
Jon
Member
6 Points
171 Posts
Re: XmlDataSource - how to specify root node
Mar 09, 2013 05:40 AM|jstranger|LINK
Obviously I need to describe my specific scenario more clearly.
Each XML element has the same name 'term' (this is a hierarchy of similar things) and 2 attributes: ID and Name. Both attribute values will be unique. What I want is to select the element with ID={aspecified value} and all its children. Presumably this will have to be done using XPath but I have read numerous tutorials and cannot find an example that helps in my case. Any help gratefully received.
Jon
Member
6 Points
171 Posts
Re: XmlDataSource - how to specify root node
Mar 09, 2013 05:54 AM|jstranger|LINK
Sorry to waste any readers' time - but I finally managed to get the XPath to work as required - as simple as "//Term[@TaxonID='n']"
Previous attempts had failed due to a case error (I hate case-sensitive languages!).
Jon
Star
9903 Points
1291 Posts
Re: XmlDataSource - how to specify root node
Mar 11, 2013 05:07 AM|Pengzhen Song - MSFT|LINK
Hi,
We are happy that your issue has been resolved. And I have marked it. Thanks for sharing solution with us.
Best Regards,
Pengzhen