XSL transform of an XML simple .NET example?

I have a .NET based application that receives an incoming XML file. I would like to convert an XML file to HTML using the XSL stylesheet that I have. This is my process ...

  • Read the submitted XML file from the file system
  • Apply XSL to XML for conversion
  • Print final HTML for display in HTML format

Does anyone have sample code that demonstrates how to do this? Thank.

+3
source share
3 answers

Here is a very short example from the MSDN.NET documentation when using a method that is a standard part of .NET (implemented in the namespace ): Transform() XslCompiledTransform System.Xml.Xsl

// Load the style sheet.
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load("output.xsl");

// Create the FileStream.
using (FileStream fs = new FileStream(@"c:\data\output.xml", FileMode.Create))
{
   // Execute the transformation.
   xslt.Transform(new XPathDocument("books.xml"), null, fs);
}

, , fs. , .

Transform() * , .

+6

, XSLT- . : Microsoft one, XSLT 1.0 Saxon XQSharp, XSLT 2.0. , , API.

+1

All Articles