- XSLT - a language for transforming XML documents
- XPath - a language for navigating in XML documents
- XSL-FO - a language for formatting XML documents
Example:
Implement Style on xml data:
*********************** Sample: Sample1.xml ************************
<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="Sample1.xslt"?>
<SqlData>
<Table>
<UserName>lakhangarg@gmail.com</UserName>
<FirstName>Lakhan Pal Garg</FirstName>
<Blog>http://www.lakhangarg.blogspot.com</Blog>
</Table>
</SqlData>
********************* XSLT Sample: Sample1.xslt ************************
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<b>Author: </b><xsl:value-of select="SqlData/Table/FirstName" /><br/>
<b>Email ID:</b><xsl:value-of select="SqlData/Table/UserName" /><br/>
<b>Blog:</b><xsl:value-of select="SqlData/Table/Blog" />
</body>
</html>
</xsl:template>
</xsl:stylesheet>
******************************************************************************
Code to implement stylesheet on xml document:
XmlDocument docXML = new XmlDocument();
XslTransform docXSL = new XslTransform();
docXML.Load(Server.MapPath("sample1.xml"));
docXSL.Load(Server.MapPath("sample1.xslt"));
Xml1.Document = docXML;
Xml1.Transform = docXSL;
******************************************************************************
Output:
Author: Lakhan Pal Garg
Email ID:lakhangarg@gmail.com
Blog:http://www.lakhangarg.blogspot.com
Email ID:lakhangarg@gmail.com
Blog:http://www.lakhangarg.blogspot.com
2 comments:
How do you print the value ??
<asp:Xml ID="Xml1" runat="server"></asp:Xml>
Use the Above XMl Control to Render the Output
Post a Comment