XML to treeview

P

Preben Zacho

Hi there

I have an XML file that looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Node xmlns="Level 1">
<Node xmlns="Level 2A">
</Node>
<Node xmlns="Level 2B">
<Node xmlns="Level 3A">
</Node>
</Node>
</Node>

I want to load this XML file into a TreeView component so it looks something
like this:

- Level 1
- Level 2A
- Level 2B
- Level 3A

I have tried alot of solutions on the internet, but most of them add extra
nodes to the treeview for each XMLNode they find. In the above example I
just want to add the 4 nodes into the treeview, not more.

Regards

/PZ
 
M

Martin Honnen

Preben said:
I want to load this XML file into a TreeView component

Which TreeView do you want to use, the one for Windows applications in
System.Windows.Forms or the one for ASP.NET 2.0 applications in
System.Web.UI.WebControls?
 
M

Martin Honnen

Preben said:
I want to load this XML file into a TreeView component so it looks something
like this:

- Level 1
- Level 2A
- Level 2B
- Level 3A

With ASP.NET 2.0 and its TreeView here is how it is possible

<asp:XmlDataSource
ID="XmlDataSource1"
runat="server"
DataFile="file.xml" ></asp:XmlDataSource>

<asp:TreeView
id="TreeView1"
runat="server"
DataSourceID="XmlDataSource1">
<DataBindings>
<asp:TreeNodeBinding DataMember="Node" TextField="xmlns" />
</DataBindings>
</asp:TreeView>
 
P

Preben Zacho

Hi Martin

I want to use the one for Windows (System.Windows.Forms).

Regards

PZ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top