2011-01-25 7 views
0

私はいくつかのコードをVBからVBに変換しようとしましたが、動作していません。それは階層的なxmlをレンダリングするはずです。asp.netで階層型XMLを表示する - VB

ここでは、コード... XMLと

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 

<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 %>' > 
      <itemTemplate> 
      <i> 
      <%# CType(Container.DataItem, XmlNode).Attributes("name").Value %> 
      </i><br /> 
      </itemTemplate> 
     </asp:Repeater> 
    </itemTemplate> 
    </asp:Repeater> 
    <hr /> 
</itemTemplate> 
</asp:Repeater> 

...

<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> 

任意のアイデアですか?

答えて

2

xmlの周囲に<xmp>というタグを付けて出力してみませんか?

<xmp>  
    <asp:literal id="myxml" runat="server" /> 
</xmp> 

と分離コードで

myxml.Text = doc.InnerXml;