Another simple method would be to specify a null resolver on either the
document or the text reader
XmlDocument doc = new XmlDocument();
doc.XmlResolver = null;
doc.Load("filepath");
OR
XmlTextReader tr = new XmlTextReader(new StreamReader("filePath"));
tr.XmlResolver = null;
XmlDocument doc = new XmlDocument();
doc.Load(tr);
This article might gives good overview of how the resolver is used :
http://msdn.microsoft.com/library/de...lResources.asp
Thanks,
Tejal.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Nat wrote:
I am reading data from an XML document with xmlDoc.load(fullname).
Unfortunately, in my xml file there is the definition of a doctype file
that is not available and so, it buggs. I would like to ignore it, to
remove this line, or I don’t know… my language is Visual C#.
Thanks in advance for your help.
You can load XML via XmlTextReader with custom XmlResolver set up. In
XmlResolver implementation (inherit XmlUrlResolver and override
ResolveUri method, see "Creating a Custom Resolver" topic in MSDN) you
can resolve DTD reference to your local copy. In fact if you don't have
teh DTD, that local copy can be even a dummy one, as XmlTextReader only
checks DTD exists and is well-formed.
--
Oleg Tkachenko [XML MVP, XmlInsider]
http://blog.tkachenko.com