displaying hierarchical xml in asp.net - vb
I've tried converting some code from c# to vb but it's not working and I'm not sure why. It's supposed to render hierarchical xml.
Here's the code...
Private Sub Page_Load(sender As Object, e As EventArgs)
Dim doc As New XmlDocument()
doc.Load(Server.MapPath("~/myxml/getbooking.xml"))
_rep1.DataSource = doc.FirstChild
_rep1.DataBind()
End Sub
and
<asp:Repeater id="_rep1" runat="server" EnableViewState="false">
<itemTemplate>
Publisher: <%# CType(Container.DataItem, XmlNode).Attributes("name").Value %><br/>
<asp:Repeater runat="server" EnableViewState="false" DataSource='<%# Container.DataItem %>' >
<itemTemplate>
Author: <%# CType(Container.DataItem, XmlNode).Attributes("name").Value %><br/>
<asp:Repeater runat="server" EnableViewState="false"
DataSource='<%# Container.DataItem %>' >
&l开发者_如何学Ct;itemTemplate>
<i>
<%# CType(Container.DataItem, XmlNode).Attributes("name").Value %>
</i><br />
</itemTemplate>
</asp:Repeater>
</itemTemplate>
</asp:Repeater>
<hr />
</itemTemplate>
</asp:Repeater>
with the xml...
<publishers>
<publisher name="New Moon Books" city="Boston"
state="MA" country="USA">
<author name="Albert Ringer ">
<title name="Is Anger the Enemy?" />
<title name="Life Without Fear" />
</author>
<author name="John White ">
<title name="Prolonged Data Deprivation " />
</author>
<author name="Charlene Locksley ">
<title name="Emotional Security: A New Algorithm" />
</author>
<author name="Marjorie Green ">
<title name="You Can Combat Computer Stress!" />
</author>
</publisher>
<publisher name="Binnet and Hardley" city="Washington"
state="DC" country="USA">
<author name="Sylvia Panteley ">
<title name="Onions, Leeks, and Garlic" />
</author>
<author name="Burt Gringlesby ">
<title name="Sushi, Anyone?" />
</author>
<author name="Innes del Castillo ">
<title name="Silicon Valley Gastronomic Treats" />
</author>
<author name="Michel DeFrance ">
<title name="The Gourmet Microwave" />
</author>
<author name="Livia Karsen ">
<title name="Computer Phobic AND Non-Phobic" />
</author>
</publisher>
<!-- ... -->
</publishers>
Any ideas?
Why not output it with the <xmp>
tag around the xml?
<xmp>
<asp:literal id="myxml" runat="server" />
</xmp>
and in the codebehind
myxml.Text = doc.InnerXml;
精彩评论