Thursday, August 1, 2013

How to Apply a XSLT on XML using Asp.Net

//Add the Following Namespaces
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;

// Use Following code to apply XSLT on xml
       string MyXmlPath = Request.PhysicalApplicationPath + "\\XMLFile.xml";
        string MyXsltPath = Request.PhysicalApplicationPath + "\\XSLTFile.xslt";
        XPathDocument xmlDoc = new XPathDocument(MyXmlPath);
        XslCompiledTransform XSLTransform = new XslCompiledTransform();
        XSLTransform.Load(MyXsltPath);
        XSLTransform.Transform(MyXmlPath, null, Response.Output);

No comments:

Post a Comment