XPathDocument xpathDocument = new XPathDocument(this.Server.MapPath("/xml/test.xml"));
XslCompiledTransform xpathTransform = new XslCompiledTransform();
StringWriter xpathWriter = new StringWriter();
XsltArgumentList xslArg = new XsltArgumentList();
xpathTransform.Load(this.Server.MapPath("/xsl/toText.xsl"));
xslArg.AddParam("path", "", imgPath); /* imgPath defined elsewhere */
xslArg.AddParam("country", "", country); /* country defined elsewhere */
xpathTransform.Transform(xpathDocument, xslArg, xpathWriter);
divXml.InnerHtml = xpathWriter.ToString(); /* divXml is a control on the ASPX page */
UPDATE: Why would you need this approach versus using the Xml control? I ran into a situation where some legacy XSL used the document() function and called a file on the network. I needed to 1) use impersonation and 2) set XmlSetting when I called Load().
No comments:
Post a Comment