Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

XslTransform.Load Method (XPathNavigator)

Loads the XSLT style sheet contained in the XPathNavigator.

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

public void Load(
	XPathNavigator stylesheet


Type: System.Xml.XPath.XPathNavigator

An XPathNavigator object that contains the XSLT style sheet.


The current node does not conform to a valid style sheet.


The style sheet contains embedded scripts, and the caller does not have UnmanagedCode permission.


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= http://www.w3.org/1999/XSL/Transform.

This method loads the XSLT style sheet, including any style sheets referenced in xsl:include and xsl:import elements. External resources are resolved using an XmlUrlResolver with no user credentials. If the style sheet(s) are located on a network resource which requires authentication, use the overload that takes an XmlResolver as one of its arguments and specify an XmlResolver with the necessary credentials.

The style sheet is loaded from the current position of the XPathNavigator. To use just a portion of the loaded document as the style sheet, navigate to the node corresponding to the beginning of the style sheet. After the Load method returns, the XPathNavigator is positioned at the beginning of the style sheet (on the xsl:style sheet node).

If the style sheet contains embedded scripting, the script is compiled to an assembly. The assembly has full trust. The recommended practice is to provide evidence using the Load(XPathNavigator, XmlResolver, Evidence) method. For issues with the Load method and style sheets with embedded scripts, see article Q316755 in the Microsoft Knowledge Base at http://support.microsoft.com.


If the caller does not have UnmanagedCode permission, the embedded script is not compiled and a SecurityException is thrown. See SecurityPermission and SecurityPermissionFlag.UnmanagedCode for more information.

.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