Article ID: 815653 - View products that this article applies to.
For a Microsoft Visual C# version of this article, see 307322
For a Microsoft Visual Basic .NET version of this article, see 300929
This article refers to the following Microsoft .NET Framework Class Library namespaces:
IN THIS TASK
This step-by-step article describes how to apply an Extensible Stylesheet Language (XSL) Transformation (XSLT) to an XML document by using the XslTransform class to create a new XML document. XSL is an XML-based language that is designed to transform one XML document into another XML document, or to transform an XML document into any other structured document.
RequirementsThe following list outlines the recommended hardware, software, network infrastructure, and service packs that you need:
Steps to Build the SampleThis example uses two files named Books.xml and Books.xsl. You can create your own Books.xml and Books.xsl files, or you can use the sample files that are included with the .NET Software Development Kit (SDK) QuickStarts. Copy the Books.xml and Books.xsl files to the folder where you create this project. You can find these files in the following folder:
\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Samples\QuickStart\Howto\Samples\Xml\Transformxml\Cs
Complete Code Sample
Note You must add the common language runtime support compiler option (/clr:oldSyntax) in Visual C++ 2005 to successfully compile the previous code sample. To add the common language runtime support compiler option in Visual C++ 2005, follow these steps:
/clr (Common Language Runtime Compilation)These steps apply to the whole article.
NOTE: While compiling above code in Visual C++ .NET 2003, you may receive C4996 compiler warning. This is due to 'System::Xml::Xsl::XslTransform::Transform' is declared deprecated.
Use following code so that you may not get C4996 compiler warning.
For more information about the XslTransform class, see the following Microsoft .NET Framework Class Library documentation:For more information about the XslTransform class with the XslTransform object, see the following Microsoft .NET Framework Developer's Guide documentation: For a practical comparison of XSLT and ASP .NET, see the following MSDN Online Voices Extreme XML column: For more information about XML in .NET, see the "XML in .NET: .NET Framework XML Classes and C# Offer Simple, Scalable Data Manipulation" article from MSDN Magazine at the following Microsoft Web site: For more general information about Visual C++ .NET or XML in .NET, see the following Usenet newsgroups: