Click here to Skip to main content
15,041,788 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am unable to get original data on webpage for treeview.
xml file:
<bookstore>
  <genre name="fiction">
    <book isbn="10-000000-001">
      <title>The Iliad and The Odyssey</title>
      <price>12.95</price>
      <comments>
        <usercomment rating="4">
          Best translation I've read.
        </usercomment>
        <usercomment rating="2">
          I like other versions better.
        </usercomment>
      </comments>
    </book>
    <book isbn="10-000000-999">
      <title>Anthology of World Literature</title>
      <price>24.95</price>
      <comments>
        <usercomment rating="3">
          Needs more modern literature.
        </usercomment>
        <usercomment rating="4">
          Excellent overview of world literature.
        </usercomment>
      </comments>
    </book>
  </genre>
  <genre name="nonfiction">
    <book isbn="11-000000-002">
      <title>Computer Dictionary</title>
      <price>24.95</price>
      <comments>
        <usercomment rating="3">A valuable resource.</usercomment>
      </comments>
    </book>
    <book isbn="11-000000-003">
      <title>Cooking on a Budget</title>
      <price>23.95</price>
      <comments>
        <usercomment rating="4">Delicious!</usercomment>
      </comments>
    </book>
  </genre>
</bookstore>

Design:
HTML
<asp:TreeView ID="TreeView1" runat="server" AutoGenerateDataBindings="False"
    DataSourceID="XmlDataSource1">
    <databindings>
        <asp:TreeNodeBinding DataMember="BookStore" Text="Book Information"
            Value="Book Information" />
        <asp:TreeNodeBinding DataMember="genre" Text="Name" Value="Name" />
        <asp:TreeNodeBinding DataMember="Book" Text="ISBN" Value="ISBN" />
    </databindings>

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

I am getting only nodes,but i need the original data in xml file.

Thanking you all.
Posted
Updated 2-Nov-11 19:41pm
v2

1 solution

Hi Srinivas

I think you need to specify XPth in XML datasource by setting xpath="BookStore/*"
or the value you required to display.

I hope this helps
Do let me know if you need any further details.

Thanks & Regards,
Sriman
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900