Formatting the parent and child nodes of a Treeview that is populated by a XML file

Posted by Marina on Stack Overflow See other posts from Stack Overflow or by Marina
Published on 2010-05-24T15:14:57Z Indexed on 2010/05/24 16:21 UTC
Read the original article Hit count: 354

Filed under:
|
|
|
|

Hello Everyone,

I'm very new to xml so I hope I'm not asking any silly question here. I'm currently working on populating a treeview from an XML file that is not hierarchically structured. In the xml file that I was given the child and parent nodes are defined within the attributes of the item element. How would I be able to utilize the attributes in order for the treeview to populate in the right hierarchical order. (Example Mary Jane should be a child node of Peter Smith). At present all names are under one another.

root

<item parent_id="0" id="1"><content><name>Peter Smith</name></content></item>
<item parent_id="1" id="2"><content><name>Mary Jane</name></content></item>
<item parent_id="1" id="7"><content><name>Lucy Lu</name></content></item>
<item parent_id="2" id="3"><content><name>Informatics Team</name></content></item>
<item parent_id="3" id="4"><content><name>Sandy Chu</name></content></item>
<item parent_id="4" id="5"><content><name>John Smith</name></content></item>
<item parent_id="5" id="6"><content><name>Jane Smith</name></content></item>

/root

Thank you for all of your help, Marina

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET