Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert xmlfile to treeView

Status
Not open for further replies.

martijn1967

Programmer
Jan 23, 2003
2
NL
Hello,

Has someone suggestions for my little problem. I just started with C# and begin to love it.

I made a complete app without any help, but now i'm facing a problem. i have an xmlfile which i like to convert to a treeview.

the xmlfile looks like:
<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
<document>
<titel>Titel</titel>
<quest>1. quest</quest>
<quest>2. quest</quest>
<quest>3. quest</quest>
<answer type=&quot;radio&quot; value=&quot;0&quot;>Radio</answer>
<answer type=&quot;radio&quot; value=&quot;1&quot;>Radio</answer>
<answer type=&quot;radio&quot; value=&quot;2&quot;>Radio</answer>
<answer type=&quot;radio&quot; value=&quot;3&quot;>Radio</answer>
<quest>4. quest</quest>
<answer type=&quot;radio&quot; value=&quot;0&quot;>Radio</answer>
<answer type=&quot;radio&quot; value=&quot;1&quot;>Radio</answer>
<answer type=&quot;radio&quot; value=&quot;2&quot;>Radio</answer>
<quest>5. quest</quest>
</document>

Could somebody tell me how to solve it?
sorry for my bad english.
 
Hi martijn1967,

In C# you have a XmlDocument object with which you can open your XML file in one shot.

You need to traverse the opened file using the XmlDocument object. From this object get a XmlNodeList or get one XmlNode at a time.

Do the same operations in reverse to creat a tree view. Except that the objects to use as TreeView and TreeNode.

eg.

XmlNodeList nodeList;
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(filename);



Regards,
Harpreet
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top