XML数据源绑定到树视图 [英] XML DataSource Binding to Tree View
本文介绍了XML数据源绑定到树视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法在网页上获取Treeview的原始数据.
xml文件:
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:
<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">
我只得到节点,但是我需要xml文件中的原始数据.
谢谢大家.
I am getting only nodes,but i need the original data in xml file.
Thanking you all.
推荐答案
斯里尼瓦斯
我认为您需要通过设置xpath ="BookStore/*"
在XML数据源中指定XPth. 或您需要显示的值.
希望对您有帮助
如果您需要更多详细信息,请告诉我.
谢谢&问候,
斯里曼
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
这篇关于XML数据源绑定到树视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文