Displaying an XML document with the Menu control. : XmlDataSource « XML « ASP.NET Tutorial






File: Data.xml

<menu>
  <category text="appetizer">
    <item text="soup" price="12.56" />
    <item text="cheese" price="17.23" />
  </category>
  <category text="entree">
    <item text="duck" price="89.21" />
    <item text="chicken" price="34.56" />
  </category>
  <category text="dessert">
    <item text="cake" price="23.43" />
    <item text="pie" price="115.46" />
  </category>
</menu>

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
   "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Menu XML Complex</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <asp:Menu
        id="Menu1"
        DataSourceID="srcMenu"
        Runat="server">
        <DataBindings>
        <asp:MenuItemBinding
            DataMember="category"
            TextField="text" />
        <asp:MenuItemBinding
            DataMember="item"
            TextField="text"
            ValueField="price" />
        </DataBindings>
    </asp:Menu>

    <asp:XmlDataSource
        id="srcMenu"
        DataFile="Data.xml"
        Runat="server" />

    </div>
    </form>
</body>
</html>








25.9.XmlDataSource
25.9.1.Create XmlDataSource
25.9.2.Displaying an XML document with the Menu control.
25.9.3.XmlDataSource and XPath
25.9.4.Transform XmlDataSource with XSLT