Loading data from a XML file in asp.net
How to display data from an xml file using xslt and asp.net
Here's a xml file showing categories of products Here is another file showing the how thjis file needs to be presented This is how the code will be calling the data and presentation together in an ASP.net file Following lines of code will give you an insight of reading data from an xml file and applying your formats and styles using XSLT
<?xml version="1.0" encoding="utf-8" ?>
<categories>
<category pid='1' name='Men'>
<subcat prefid="11">Short sleeves</subcat>
<subcat prefid="12">Long Sleeves</subcat>
<subcat prefid="13">Tanks</subcat>
<subcat prefid="14">Sleeveless</subcat>
</category>
<category pid="2" name="Ladies" >
<subcat prefid= "21"> Short sleeves </subcat>
<subcat prefid="22"> Long Sleeves </subcat>
<subcat prefid="23"> Tanks </subcat>
</category>
<category pid="3" name="Athletic" >
<subcat prefid= "31"> Short sleeves </subcat>
<subcat prefid="32"> Long Sleeves </subcat>
<subcat prefid="33"> Tanks </subcat>
</category>
</categories>
<?xml version="1.0"?>
<!-- This is a non-standard style sheet designed just for
Internet Explorer. It will not work with any standards
compliant XSLT processor. -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html"/>
<xsl:template match="category">
<table width="50%" columns="2">
<th><td>
<xsl:variable name="category" select="@pid" />
<xsl:value-of select="@name"/>
</td><tr>
<td>
<img>
<xsl:attribute name="SRC">
<xsl:value-of select="@img" />
</xsl:attribute>
<xsl:attribute name="ALT">
<xsl:value-of select="@alt" />
</xsl:attribute>
</img>
</td>
</tr>
</th>
<tr><td>
<xsl:apply-templates/>
</td></tr></table>
</xsl:template>
<xsl:template match="/categories/category/subcat">
<td>
<asp:Xml id="Xml1" runat="server" TransformSource="style.xslt" DocumentSource="categories.xml"></asp:Xml>