I've got an XML document, which Im trying to add an xslt to in c# and output to screen. I've been doing some research on this and it looks like I need to use the XslCompiledTransform class to do this.
The problem is, when I call the Load method,my page errors. All the samples I have found online seem to suggest I just call the load like "Sort.xsl" - which is in the same folder as this file. Im also assuming I need to use the MemoryStream() to display the transformed xml to screen?
Im using the XmlDocument to do all my processing and all data is in "xmlDocument". Can someone help me load the external xsl, apply it and the display results to screen.
Many thanks
// Create a writer for writing the transformed file.
MemoryStream strm = new MemoryStream();
XmlWriter writer = XmlWriter.Create(strm);
// Create and load the transform with script execution enabled.
XslCompiledTransform transform = new XslCompiledTransform();
XsltSettings settings = new XsltSettings();
settings.EnableScript = true;
transform.Load(@"Convert.xsl", settings, null);
// Execute the transformation.
transform.Transform(xmlDocument, Response.OutputStream);