Getting XPath from a TreeNode

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Good day,
I have a treeview and filled it with an XML content. The user can click on each element (TreeNode). When user clicks the element, the attributes inside that element are shown in the other ListBox control. Currently I already have logic for Getting Element
XPath & just append the Attribute selected in the ListBox. However, this does not work on when we have something like XML having namespaces... example :
<pre class="prettyprint <?xml version="1.0"?>
<library xmlns="http://eric.van-der-vlist.com/ns/library
<book id="b0836217462" available="true
<character id="PP
<name xmlns="http://eric.van-der-vlist.com/ns/person Peppermint Patty</name>
<born xmlns="http://eric.van-der-vlist.com/ns/person 1966-08-22</born>
<qualification>bold, brash and tomboyish</qualification>
</character>
</book>
</library>
[/code]
if we choose the element name or born ... my code fails.. (but no namespace it will work, but i need to support namespace).. so Im thinking to re-do the XPath generation from scratch and also tried using XElement.Parse but was not successful...
How can we generate an XPath based from a TreeNode, and at the same time get the Attributes?
Thanks<br/>

<br/>



View the full article
 
Back
Top