System.Xml.XmlDocument.XmlResolver Property

Sets the System.Xml.XmlResolver to use for resolving external resources.

Syntax

public virtual XmlResolver XmlResolver { set; }

Value

An System.Xml.XmlResolver object to resolve external resources, or null to prohibit to resolve external resources.

Remarks

The XmlResolver can be used to load DTDs or expand entity references. Using the XmlResolver.Credentials property, you can set credentials on the XmlResolver to access resources stored on a secure network resource.

  • If the document was not loaded using an System.Xml.XmlReader (that is, if it was loaded using a stream, file, and so on) the XmlResolver on the XmlDocument is always used.

  • If the document was loaded with an System.Xml.XmlTextReader, the resolver on the XmlTextReader is used to resolve any DTD references in the DocumentType node. The resolver on the XmlDocument is used to expand any entity references.

  • If the document was loaded with an System.Xml.XmlValidatingReader, the resolver on the XmlDocument is never used.

  • If the document was loaded with a class that extends XmlReader and the XmlReader cannot resolve entities (XmlReader.CanResolveEntity returns false), the XmlResolver on the XmlDocument is used to resolve any references in the DocumentType node and to expand any entity references.

Note:

If the XmlDocument is loaded using an System.Xml.XmlReader which had an XmlResolver set to it, the XmlResolver on the XmlReader is not cached by the XmlDocument after XmlDocument.Load(string) completes.

In version 1.1 of the.NET Framework, if this property is not set, the trust level of the application determines the default behavior.

Fully trusted code: The document uses a default System.Xml.XmlUrlResolver with no user credentials. If authentication is required to access a network resource, use the XmlResolver property to specify an XmlResolver with the necessary credentials.

Semi-trusted code: The XmlResolver property is set to null. External resources are not resolved.

For more information on security and the XmlResolver property, see [<topic://cpconresolvingexternalresources>].

This property is a Microsoft extension to the Document Object Model (DOM).

Requirements

Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0