ASP.NET Tutorial/XML/DataList
Using a DataList control to display XML content
<source lang="csharp">
<%@ Page Language="C#"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server"> <title>XmlDataSource</title> </head> <body> <form id="form1" runat="server"> <asp:datalist id="DataList1" DataSourceID="XmlDataSource1" runat="server"> <ItemTemplate> <%# XPath("author/first-name") %> <%# XPath("author/last-name")%> wrote <%# XPath("title") %> </ItemTemplate> </asp:datalist> <asp:xmldatasource id="XmlDataSource1" runat="server" datafile="~/Data.xml" xpath="//bookstore/book"/> </form> </body>
</html> File: Data.xml <?xml version="1.0"?> <bookstore xmlns="http://example.books.ru"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <book genre="A" publicationdate="1981" ISBN="1-11111-11-0"> <title>title 1</title> <author> <first-name>A</first-name> <last-name>B</last-name> </author> <price>8</price> </book> <book genre="B" publicationdate="1999" ISBN="0-222-22222-2"> <title>title 2</title> <author> <first-name>C</first-name> <last-name>D</last-name> </author> <price>11.99</price> </book>
</bookstore></source>