Resolving Resources Using the XmlResolver 

The XmlValidatingReader class uses XmlResolver to resolve external DTDs, entities, and schemas. In order to resolve these external resources, the XmlResolver property in XmlValidatingReader must be set. The following example shows how to set the resolver to resolve an external DTD resource used by XmlValidatingReader.

dim vreader as New XmlValidatingReader(new XmlTextReader("https://www.alpineskihouse.org/abc.xml"))
dim resolver As new XmlUrlResolver()
vreader.XmlResolver = resolver
While (vreader.Read())
    . . . 
End While
XmlValidatingReader vreader = 
    new XmlValidatingReader(new XmlTextReader("https://www.alpineskihouse.org/abc.xml"));
vreader.XmlResolver = new XmlUrlResolver();
while(vreader.Read())
   {
       . . . 
   }

To resolve a DTD, XmlValidatingReader calls the GetEntity method to get a stream representation of the entity. If the URI of the DTD is a relative URI, then XmlValidatingReader calls the ResolveUri method and returns an absolute URI for the given relativeUri and baseUri. If XmlResolver does not know how to resolve the given URI, then it returns a null reference.

Additionally, if security settings are required to access the external resource, then the Credentials property can be set accordingly. This property enables the user to set authentication settings for URIs. For more information on supplying credentials, see Supplying Authentication Credentials to XmlResolver when Reading from a File.

The GetEntity method in the XmlUrlResolver uses the information in the Credentials property as appropriate to gain access to the resource. There is no get accessor to this property for security reasons. When overwriting XmlResolver, GetEntity is the method that utilizes the credential information in the Credentials property.

If you do not provide an XmlResolver for the XmlValidatingReader to use, then a default XmlUrlResolver is created and null credentials are used.

Resolving all other XML resources is very similar to resolving DTDs. XmlResolver needs to know only how to negotiate the connection with the external resource, and return a Stream representation of the content. It is the object that is making the call to XmlResolver that has the task of interpreting the stream.

See Also

Concepts

Supplying Authentication Credentials to XmlResolver when Reading from a File

Other Resources

Resolve External XML Resources Named by a URI