Mega Code Archive

 
Categories / ASP.Net / XML
 

Use asp

<%@ 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 runat="server">     <title>Untitled Page</title> </head> <body>     <form id="form1" runat="server">     <div>     <asp:Xml id="Xml1"               runat="server"               DocumentSource="Data.xml"               TransformSource="Data.xslt"></asp:Xml>     </div>     </form> </body> </html> File: Data.xslt <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/Data">   <xsl:for-each select="Category">     <b><xsl:value-of select="@title"/></b><br/>     <xsl:for-each select="Product">       -<xsl:value-of select="@title"/><br/>     </xsl:for-each>   </xsl:for-each> </xsl:template> </xsl:stylesheet> File: Data.xml <?xml version="1.0"?> <Data>   <Category title="DVD">     <Product title="A" />     <Product title="B" />   </Category>   <Category title="Books">     <Product title="C" />     <Product title="D" />     <Product title="E" />   </Category> </Data>