Mark Wilson I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :
03/24/2008
Times viewed :
233
The System.Xml.XmlUrlResolver Class
Supported Versions
.NET Framework 1.0, 1.1, 1.2
Public Members
Bold members are covered in the sample code.
Public Properties
Public Methods
Credentials
Equals
NameTable
GetEntity
GetHashCode
GetType
ResolveUri
ToString
Overview
This class is a concrete implementation of the XmlResolver
class, and acts as the default resolver class used within the System.Xml
library. Its primary function is to resolve references to external DTD, XML
Schema, and XSL documents.
Example #1 (VB.NET):
How to turn off the XmlResolver on an XmlTextReader object.
In the example below we create an XmlTextReader that reads
in the contents of an XML document containing an *invalid* reference to an
external Document Type Definition. The XmlTextReader.XmlResolver property is intentionally
set to nothing, allowing the XmlTextReader to ignore the DTD reference.
Dim objXmlTextReader As System.Xml.XmlTextReader
Dim objXmlUrlResolver As System.Xml.XmlUrlResolver
Dim strValues As String
objXmlTextReader = New
XmlTextReader("c:\note.xml")
objXmlTextReader.XmlResolver = Nothing
strValues = "First Try - no resolver" & CrLf
While (objXmlTextReader.Read)
strValues &= objXmlTextReader.ReadInnerXml
End While
TextBox1.Text = strValues
Example #2
(VB.NET): How to explicitly assign an XmlUrlResolver object to an XmlTextReader
object.
(This is a continuation of our previous example.) We now
explicitly create an XmlUrlResolver object and assign it to the XmlTextReader
object. By doing so the XmlTextReader.Read method is forced to check the DTD
reference. Upon discovering that the reference is invalid, an error is
generated and displayed.