Mega Code Archive

 
Categories / ASP.Net Tutorial / XML
 

XML transform with 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.xsl">         </asp:Xml>     </div>     </form> </body> </html> File: Data.xml <?xml version="1.0" standalone="yes"?> <!--Created with the XmlDocument class.--> <SuperProProductList  >     <Product ID="1" Name="Chair">         <Price>49.33</Price>     </Product>     <Product ID="2" Name="Car">         <Price>43.55</Price>     </Product>     <Product ID="3" Name="Fresh Fruit Basket">         <Price>49.99</Price>     </Product> </SuperProProductList> File: Data.xsl <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"     version="1.0" >   <xsl:template match="SuperProProductList">     <html><body><table border="1">     <xsl:apply-templates select="Product"/>     </table></body></html>   </xsl:template>      <xsl:template match="Product">     <tr>     <td><xsl:value-of select="@ID"/></td>     <td><xsl:value-of select="@Name"/></td>     <td><xsl:value-of select="Price"/></td>     </tr>   </xsl:template> </xsl:stylesheet>