XmlDocument Input to XslTransform

The XmlDocument class provides editing capabilities for an XML document. If the XML needs to be edited or modified before being sent to the Transform method, load the XML into an XmlDocument, edit it, and send it in to the XslTransform.


The XslTransform class is obsolete in the .NET Framework 2.0. You can perform Extensible Stylesheet Language for Transformations (XSLT) transformations using the XslCompiledTransform class. See Using the XslCompiledTransform Class and Migrating From the XslTransform Class for more information.

The XmlDocument implements the IXPathNavigable interface, so the document can be passed to the Transform method after editing.

Due to the editing capability of the XmlDocument, using the XmlDocument class as input to a transformation is slower than using an XPathDocument for the Extensible Stylesheet Language for Transformations (XSLT) transformations, as the XPathDocument is optimized for XML Path Language (XPath) queries due to the internal storage.


The following code example shows how an XmlDocument can be supplied to the XslTransform, with the output sent to an XmlReader.

Dim doc as XmlDocument = new XmlDocument()  
Dim trans As XslTransform = new XslTransform()  
Dim rdr As XmlReader = trans.Transform(doc, Nothing, Nothing)  
while (rdr.Read())  
end while  
XmlDocument doc = new XmlDocument();  
XslTransform trans = new XslTransform();  
XmlReader rdr = trans.Transform(doc, null, null);  
while (rdr.Read()) {}  

See Also

XSLT Transformations with the XslTransform Class
XslTransform Class Implements the XSLT Processor
XPathNavigator in Transformations
XPathNodeIterator in Transformations
XPathDocument Input to XslTransform
XmlDataDocument Input to XslTransform