Blowfelt82
asked on
Populate C# treeview using XML source data
I have the following XML:
and am using the following to iterate through a list of the cases:
What I am looking for is a way to populate a C# based treeview object based on the XElements obtained. The office attribute should be the parent nodes within the tree and then a child node based on the name attrbiutes 'type' e.g. type1 and then the full name itself. If a parent of child node already exists the current node should be added to the existing node structure. So the above would look like...
I would like to implement this as part of a C# solution and am a bit of a newbie. Also I would like the ability to control the apperance and event handlers of the individual tree nodes - which I think I can work out myself but would like the solution to give me some access to the tree nodes being added to facilitate this.
<cases>
<case name="active_type1_smith_1" office="newcastle" />
<case name="active_type1_jones_1" office="sunderland" />
<case name="active_type2_elliott_1" office="newcastle" />
<case name="active_type2_davies_1" office="london" />
</cases>
and am using the following to iterate through a list of the cases:
XDocument.Load("case.xml");
foreach(XElement Case In (XDocument.Load("case.xml").Descendants().Where(node => node.Name == "case")
{
...
}
What I am looking for is a way to populate a C# based treeview object based on the XElements obtained. The office attribute should be the parent nodes within the tree and then a child node based on the name attrbiutes 'type' e.g. type1 and then the full name itself. If a parent of child node already exists the current node should be added to the existing node structure. So the above would look like...
newcastle
type1
active_type1_smith_1
type2
active_type2_elliott_1
sunderland
type1
active_type1_jones_1
london
type2
active_type2_davies_1
I would like to implement this as part of a C# solution and am a bit of a newbie. Also I would like the ability to control the apperance and event handlers of the individual tree nodes - which I think I can work out myself but would like the solution to give me some access to the tree nodes being added to facilitate this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.