Binding The TreeView Control to XML Data

To bind the TreeView control to XML data, I have taken the XmlDataSource in which I have define an Xpath and a DataFile.

Here is my sample code:

<asp:XmlDataSource ID="PageDataSource" runat="server" XPath="/PageTitle" DataFile="~/App_Data/PageTitle.xml" />
<asp:TreeView ID="PageTreeView" runat="server" DataSourceID=" PageDataSource ">
    <asp:TreeNodeBinding DataMember="Id" TextField="#InnerText"  />
    <asp:TreeNodeBinding DataMember="Tite" TextField="#InnerText" />
    <asp:TreeNodeBinding DataMember="PageUrl" TextField="#InnerText" />

In the page load simply write:

protected void Page_Load(object sender, EventArgs e)
    PageDataSource.XPath = "/PageTitle";

Lastly, here is the XML file:

<?xml version="1.0" encoding="UTF-8"?>




    <Tite>This is my testing</Tite>

    <PageUrl>mybook /1/1.aspx</PageUrl>




    <Tite>This is my testing</Tite>

    <PageUrl> mybook /2/2.aspx</PageUrl>