XML transform with asp:XML : Xml control « XML « ASP.NET Tutorial






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








25.7.Xml control
25.7.1.XML transform with asp:XML
25.7.2.setup the xml control