Transforming Xml Data Into Html - Presentation Transcript
Transforming XML data into HTML http://www.livetolearn.in
XSL
An Extensible stylesheet Language (XSL) transformation pulls data from XML nodes and renders the content according to given instructions
We can render the raw data as attractive HTML on an ASP.NET page.
http://www.livetolearn.in
Add a new XML file named links.xml to the App_Data folder
Enter the following sample data:
<? xml version = " 1.0 " encoding = " utf-8 " ?> < links > < link > < title > Microsoft Official ASP.NET site </ title > < url > http://www.asp.net </ url > < description > The primary site for ASP.NET developers. </ description > </ link > < link > < title > Collection of Tutorials, Ebooks, Videos </ title > < url > http://www.livetolearn.in </ url > < description > Computer Programming Tutorials, Tutorial Sites, E-books, Videos, Powerpoint Presentations </ description > </ link > </ links > http://www.livetolearn.in
Add xslt stylesheet file in root folder and replace with the following content <? xml version ="1.0" encoding ="utf-8"?> < xsl:stylesheet version ="1.0" xmlns:xsl ="http://www.w3.org/1999/XSL/Transform"> < xsl:template match ="/links"> < xsl:for-each select ="link" > < p class ="headingtitle"> < xsl:value-of select ="title"/> </ p > < div class ="content"> URL: < xsl:value-of select ="url"/> </ div > Description: < xsl:value-of select ="description"/> < hr /> </ xsl:for-each > </ xsl:template > </ xsl:stylesheet > http://www.livetolearn.in
Add a asp.net page xmltohtml.aspx
Add a Xml Control from Toolbox
On the Xml control’s property window set the following properties
http://www.livetolearn.in
Now, add styles as you want with in <head> tag in the aspx file
For example add the following code or define it by clicking New Style in the sidebar
0 comments
Post a comment