Load tranformation file from the web : Transform « XML « ASP.Net






Load tranformation file from the web

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Xml.Xsl" %>
<%@ Import Namespace="System.Xml.XPath" %>

<script runat="server">                
    void Page_Load(object sender, System.EventArgs e)
  {
        string xmlPath = Request.PhysicalApplicationPath + @"\Books.xml";        
        XmlSecureResolver resolver = new XmlSecureResolver(new XmlUrlResolver(), "http://localhost");
        NetworkCredential cred = new NetworkCredential("Administrator", "thiru","THIRU-SERVER3");
        resolver.Credentials = cred;
      XPathDocument xpathDoc = new XPathDocument(xmlPath);      
        XslCompiledTransform transform = new XslCompiledTransform();
        XsltSettings settings = new XsltSettings();
        settings.EnableDocumentFunction = true;
        //Load the XSL stylsheet into the XslCompiledTransform object
        transform.Load("http://localhost/Books.xsl", settings, resolver);                
        transform.Transform(xpathDoc, null, Response.Output);            
    }        
</script>
           
       








Related examples in the same category

1.Applying XSL Transformation on an XmlDataSource Control
2.Simplest XML transform
3.XML transformation with parameter
4.XML transformation with extension
5.XML transformation with script in the xls
6.Passing a Nodeset as a Parameter in XML transformation