programmer1024
Member
- Joined
- Jun 18, 2006
- Messages
- 23
- Programming Experience
- 3-5
I don't have a solid skillset in XML, and when I try to understand how to process (read/write) XML documents/files I get confused.
I have to parse the an XML document that looks like the following:
This data has to be inserted into a treeview control.
Each level 1 node gets a node added on the root node and each level 2 node gets a node added on the node of the previous level 1 node.
For example,
Root
------>Security (level 1 node)------>Ad Aware (level 2 node)
------>Office (level 1 node)------>Word & Powerpoint (level 2, separate nodes)
Using examples on the net, I try using XMLTextReader as a sort of text document reader, and XMLDocument's GetElementByName.
I get to about halfway, but I think my code is much more complicated than what is necessary. Also, adding the appropriate level 2 nodes to their parent nodes is a bit confusing.
I have to parse the an XML document that looks like the following:
HTML:
<?xml version="1.0" encoding="utf-8" ?>
<tree>
<nodeobject level="1">
<nodetext>Security</nodetext>
<nodetag></nodetag>
</nodeobject>
<nodeobject level="2">
<nodetext>Ad Aware</nodetext>
<nodetag>C:\Program Files\Lavasoft\</nodetag>
</nodeobject>
<nodeobject level="2">
<nodetext>Avast!</nodetext>
<nodetag>C:\Program Files\Alwil\</nodetag>
</nodeobject>
<nodeobject level="1">
<nodetext>Office</nodetext>
<nodetag></nodetag>
</nodeobject>
<nodeobject level="2">
<nodetext>Word</nodetext>
<nodetag>C:\Program Files\MS Office\</nodetag>
</nodeobject>
<nodeobject level="2">
<nodetext>Powerpoint</nodetext>
<nodetag>C:\Program Files\MS Office\</nodetag>
</nodeobject>
</tree>
Each level 1 node gets a node added on the root node and each level 2 node gets a node added on the node of the previous level 1 node.
For example,
Root
------>Security (level 1 node)------>Ad Aware (level 2 node)
------>Office (level 1 node)------>Word & Powerpoint (level 2, separate nodes)
Using examples on the net, I try using XMLTextReader as a sort of text document reader, and XMLDocument's GetElementByName.
I get to about halfway, but I think my code is much more complicated than what is necessary. Also, adding the appropriate level 2 nodes to their parent nodes is a bit confusing.
Last edited by a moderator: