Transform Method (String, String)

XslTransform.Transform Method (String, String)

Transforms the XML data in the input file and outputs the result to an output file.

Namespace:  System.Xml.Xsl
Assembly:  System.Xml (in System.Xml.dll)

public void Transform(
	string inputfile,
	string outputfile


Type: System.String

The URL of the source document to be transformed.

Type: System.String

The URL of the output file.


The XslTransform class is obsolete in the .NET Framework version 2.0. The XslCompiledTransform class is the new XSLT processor. For more information, see Using the XslCompiledTransform Class and Migrating From the XslTransform Class.

XslTransform supports the XSLT 1.0 syntax. The XSLT style sheet must include the namespace declaration xmlns:xsl=


This method is obsolete in version 1.1 of the .NET Framework. The setting of the XmlResolver property determines how the XSLT document() function is resolved. The recommended practice is to use the Transform method which takes an XmlResolver object as one of its arguments.

The following example transforms the books.xml file using the output.xsl style sheet and outputs the results to the books.html file.

//Create the XslTransform object.
XslTransform xslt = new XslTransform();

//Load the stylesheet.

//Transform the file.
xslt.Transform("books.xml", "books.html");

The sample uses the following two input files:


<?xml version='1.0'?>
<!-- This file represents a fragment of a book store inventory database -->
  <book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
    <title>The Autobiography of Benjamin Franklin</title>
  <book genre="novel" publicationdate="1967" ISBN="0-201-63361-2">
    <title>The Confidence Man</title>
  <book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6">
    <title>The Gorgias</title>


<xsl:stylesheet xmlns:xsl="" version="1.0">
<xsl:template match="bookstore">
      <TABLE BORDER="2">
        <xsl:apply-templates select="book"/>
<xsl:template match="book">
    <TD><xsl:value-of select="@ISBN"/></TD>
    <TD><xsl:value-of select="title"/></TD>
    <TD><xsl:value-of select="price"/></TD>

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.0
Obsolete (compiler warning) in 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft