Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Transforming Xml Data Into Html

2,018 views

Published on

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

  • Be the first to comment

  • Be the first to like this

Transforming Xml Data Into Html

  1. 1. Transforming XML data into HTML http://www.livetolearn.in
  2. 2. XSL <ul><li>An Extensible stylesheet Language (XSL) transformation pulls data from XML nodes and renders the content according to given instructions </li></ul><ul><li>We can render the raw data as attractive HTML on an ASP.NET page. </li></ul>http://www.livetolearn.in
  3. 3. <ul><li>Add a new XML file named links.xml to the App_Data folder </li></ul><ul><li>Enter the following sample data: </li></ul><? xml version = &quot; 1.0 &quot; encoding = &quot; utf-8 &quot; ?> < 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
  4. 4. Add xslt stylesheet file in root folder and replace with the following content <? xml version =&quot;1.0&quot; encoding =&quot;utf-8&quot;?> < xsl:stylesheet version =&quot;1.0&quot; xmlns:xsl =&quot;http://www.w3.org/1999/XSL/Transform&quot;> < xsl:template match =&quot;/links&quot;> < xsl:for-each select =&quot;link&quot; > < p class =&quot;headingtitle&quot;> < xsl:value-of select =&quot;title&quot;/> </ p > < div class =&quot;content&quot;> URL: < xsl:value-of select =&quot;url&quot;/> </ div > Description: < xsl:value-of select =&quot;description&quot;/> < hr /> </ xsl:for-each > </ xsl:template > </ xsl:stylesheet > http://www.livetolearn.in
  5. 5. <ul><li>Add a asp.net page xmltohtml.aspx </li></ul><ul><li>Add a Xml Control from Toolbox </li></ul><ul><li>On the Xml control’s property window set the following properties </li></ul>http://www.livetolearn.in
  6. 6. <ul><li>Now, add styles as you want with in <head> tag in the aspx file </li></ul><ul><li>For example add the following code or define it by clicking New Style in the sidebar </li></ul>< style type =&quot;text/css&quot;> .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
  7. 7. Now, browse it (F5 / Ctrl+F5) http://www.livetolearn.in

×