.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Code Snippets >> XML >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

XML to HTML transformation using Xslt

Posted By:Sajid P K       Posted Date: October 14, 2010    Points: 15    Category: XML    URL: http://www.dotnetspark.com  

This code segment explain you, how to transform a XML file to HTML using XSLT.

Namespace Used:

1. System.Xml
2. System.Xml.XPath
3. System.Xml.Xsl

public static void Transform(string sXmlPath, string sXslPath)
      // Step 1:   load the Xml doc  
       XPathDocument myXPathDoc = new XPathDocument(sXmlPath) ;           
       XslTransform myXslTrans = new XslTransform() ;  

     // Step 2:   load the Xsl  
      myXslTrans.Load(sXslPath) ;   

     // Step 3:   create the output stream 

XmlTextWriter myWriter = new XmlTextWriter("result.html", null); // Step 4: do the actual transform of Xml


myXslTrans.Transform(myXPathDoc,null, myWriter); myWriter.Close() ; } catch(Exception e) { Console.WriteLine("Exception: {0}", e.ToString()); } }


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend