NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

XslTransform Class

Transforms XML data using an XSL stylesheet.

Object
   XslTransform

[Visual Basic]
Public Class XslTransform
[C#]
public class XslTransform
[C++]
public __gc class XslTransform
[JScript]
public class XslTransform

Remarks

To transform XML data:

  1. Create an XslTransform object.
  2. Load the stylesheet to use for the transformation into the XslTransform object using the Load method. There are three overloads for this method: each one for a different type of object supplying the XSL stylesheet: URL, XmlReader, and XmlNavigator.
  3. Create an XmlNavigator object and initialize it with an XmlDocument that contains the XML data you want to transform.
  4. Transform the XML data using the Transform method. Specify the XmlNavigator for XML data as the input parameter. There are four overloads for this method: each one is for a different type of output: XmlReader, XmlWriter, Stream, andTextWriter.

Requirements

Namespace: System.NewXml.Xsl

Assembly: System.Xml.dll

Example [C#]

The following example transforms the specified XML document using the specified stylesheet and outputs the result to the console using XmlWriter.

[C#]

//Create a new XslTransform
XslTransform xslt = new XslTransform();
//Load an XSL stylesheet
xslt.Load("http://somewhere/favorite.xsl");
//Create a new XmlDocument to load XML data from a file.
XmlDocument mydata = new XmlDocument()
//Load the XML data file
mydata.Load("http://somewhere/mydata.xml");
//Create an XmlTextWriter to transform output to the console.
XmlWriter writer = new XmlTextWriter(Console.Out);
//Transform the data and output the result.
xslt.Transform(new XmlDocumentNavigator(mydata),null,writer);

See Also

XslTransform Members | System.NewXml.Xsl Namespace