When overridden in a derived class, specifies the System.Xml.XmlNamespaceManager object to use for namespace resolution.
- nsManager
- An System.Xml.XmlNamespaceManager object to use for namespace resolution.
Namespace resolution is supported using the System.Xml.XmlNamespaceManager class which stores prefix and namespace Uniform Resource Identifier (URI) mappings. If the System.Xml.XPath.XPathExpression requires namespace resolution, the prefix and namespace URI pair must be added to the System.Xml.XmlNamespaceManager object and the XPathExpression.SetContext(System.Xml.XmlNamespaceManager) method must be called to specify the System.Xml.XmlNamespaceManager object to use for namespace resolution.
The following are important notes to consider when using the XPathExpression.SetContext(System.Xml.XmlNamespaceManager) method.
If the System.Xml.XPath.XPathExpression does not include a prefix, it is assumed that the namespace URI is the empty namespace. If your XML includes a default namespace, you must still use the XPathExpression.SetContext(System.Xml.XmlNamespaceManager) method and provide an System.Xml.XmlNamespaceManager object that contains a prefix and namespace URI to handle the default namespace.
You can also supply an System.Xml.IXmlNamespaceResolver object for namespace resolution to the XPathExpression.Compile(string, System.Xml.IXmlNamespaceResolver) method when you create your System.Xml.XPath.XPathExpression object.
XPathExpression.SetContext(System.Xml.IXmlNamespaceResolver) accepts System.Xml.Xsl.XsltContext as a namespace resolver, so you can implement a custom context and use functions and variables based on System.Xml.Xsl.IXsltContextFunction and System.Xml.Xsl.IXsltContextVariable. The XPath expression will execute them. For more information, see User Defined Functions and Variables.