Transform XML into HTML using a XSL Stylesheet in C#.NET



Transform XML into HTML using a XSL Stylesheet in C#.NET

//import name spaces
using System.Xml.Xsl;
using System.Xml.XPath;
using System.IO;
using System.Xml;

public static void Transform(string XmlPath, string XslPath){
        
        try{
            
            //load the Xml doc
            XPathDocument XPathDoc = new XPathDocument(XmlPath) ;

            XslTransform XslTrans = new XslTransform() ;
            
            //load the Xsl 
            XslTrans.Load(XslPath) ;
            
            //create the output stream
            XmlTextWriter Writer = new XmlTextWriter
				("result.html", null);
            
            //do the actual transform of Xml
            XslTrans.Transform(XPathDoc,null, Writer);        

            Writer.Close() ;


        }
          catch(Exception ex)
        {

            Response.Write(ex.Message);
        }
        
        }

Share |

 Cant find the page you are looking for?
 Help us to improve by adding the content that you are looking for.
 Leave a feedback
 We look forward to hear your comments and feedback.