7.15. Perform an XSL Transform

Problem

You need to transform an XML document into another document using an XSLT style sheet.

Solution

Use the System.Xml.Xsl.XslCompiledTransform class. Load the XSLT style sheet using the XslCompiledTransform.Load method, and generate the output document by using the Transform method and supplying a source XML document.

How It Works

XSLT (or XSL transforms) is an XML-based language designed to transform one XML document into another document. You can use XSLT to create a new XML document with the same data but arranged in a different structure or to select a subset of the data in a document. You can also use it to create a different type of structured document. XSLT is commonly used in this manner to format ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.