User Id :    Password :      New Member   Forgot Password  
 
How to use XSLT
Description what is XSLT and how to use it to transform a xml document using a simple example   No. of Views     1454
  Rating     5
Author Sumit Gupta   Posted On     22 Mar 2010
Tags ASP.NET,C#,XML,Xslt    

Sample Code   Download Code

Simple XSLT Example Introduction In this article i am explaining what is XSLT and how to use it to transform a xml document using a simple example. What is XSLT XSLT stands for EXtensible Stylesheet Language Transformations. XSLT transforms an XML document into another XML document, or another type of document that is recognized by a browser, like HTML. With XSLT you can add/remove elements and attributes to or from the output file. You can also rearrange and sort elements, perform tests and make decisions about which elements to hide and display, and a lot more. Using Code Using code you can easily transform a xml document into other xml document with style like following figure: The code of xslt file is as follow:
 



         

CD Collection

Title Artist Country Company Price





Explaination of Code First tag define that it is an xml file because xslt is also an xml file Then second tag declares the document to be an XSL style sheet is To get access to the XSLT elements, attributes and features we must declare the XSLT namespace at the top of the document. The xmlns:xsl="http://www.w3.org/1999/XSL/Transform" points to the official W3C XSLT namespace. If you use this namespace, you must also include the attribute version="1.0". Element The element is used to build templates. The match attribute is used to associate a template with an XML element. The match attribute can also be used to define a template for the entire XML document. The value of the match attribute is an XPath expression (i.e. match="/" defines the whole document). The content inside the element defines some HTML to write to the output. The element can be used to extract the value of an XML element and add it to the output stream of the transformation like





Element The XSL element can be used to select every XML element of a specified node-set
            
       
...










About Author

About Author I am Sumit Gupta working in 3 Pillar Global Pvt. Ltd as Module Lead. I have 7+ year of experience in .Net technologies. I love to explore new technologies and write technical article. Sumit Gupta
No Photo
 
Country India
Company 3 Pillar Global Pvt. Ltd.
Home Page http://www.facebook.com/sumitgupta1225

Rate this article

Rating options from poor, fair, good, very good to excelent.  
 

Comments

 
 
Posted By Annonymous on 03 Sep 2011 at 05:51 AM
 
If you're reiandg this, you're all set, pardner!
 
 
   
Write your comment here.
Comment
Verification Code