How to Show an .Xml or .Dtd in TreeView
- 1). Click the Windows "Start" button and type "visual studio" in the menu text box. Press "Enter" to open the software. Open the XML and DTD project to load the code in the editor.
- 2). Open the file that contains the TreeView control. You can also drag and drop a TreeView control from the VS toolbox on the left side of the work space to the form. Notice the ASP HTML automatically generates on the ASP form.
- 3). Add the XML data source to the beginning of the file. You must load the file before binding it to the TreeView, so you must add the following code before the ASP code that defines the TreeView:
<asp:XmlDataSource ID="mydata" runat="server" XPath="/PageTitle" DataFile="~/xm/datafile.xml" /> - 4). Bind the TreeView to the DataSource object created in Step 3. The following code loads the XML data into the TreeView:
<asp:TreeView ID="treeview1" runat="server" DataSourceID=" mydata">
<DataBindings>
<asp:TreeNodeBinding DataMember="mydata_id" TextField="#InnerText" />
</DataBindings>
</asp:TreeView> - 5). Click the "Save" button. Click "Run" to execute the code and review the results of the data binding.
Source...