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);
}
}