transforming xml data into html

7
Transforming XML data Transforming XML data into HTML into HTML http://www.livetolearn.in

Upload: karthikeyan-mkr

Post on 18-Dec-2014

1.620 views

Category:

Documents


3 download

DESCRIPTION

Transforming XML data into HTML Markupbyhttp://www.livetolearn.in

TRANSCRIPT

Page 1: Transforming Xml Data Into Html

Transforming XML data Transforming XML data into HTML into HTML

http://www.livetolearn.in

Page 2: Transforming Xml Data Into Html

XSLXSLAn 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

Page 3: Transforming Xml Data Into Html

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

Page 4: Transforming Xml Data Into Html

Add xslt stylesheet file in root Add xslt stylesheet file in root folder and replace with the folder and replace with the following contentfollowing 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

Page 5: Transforming Xml Data Into Html

Add a asp.net page xmltohtml.aspxAdd a Xml Control from ToolboxOn the Xml control’s property window

set the following properties

http://www.livetolearn.in

Page 6: Transforming Xml Data Into Html

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

<style type="text/css"> .headingtitle { font-weight: bold; background-color: #FFFF00; border-style: ridge; } .content { background-color: #99CCFF; font-weight: bold; border-style: outset; } </style>

http://www.livetolearn.in

Page 7: Transforming Xml Data Into Html

Now, browse it (F5 / Ctrl+F5)Now, browse it (F5 / Ctrl+F5)

http://www.livetolearn.in