> I'm trying to load an XML file, that references a DTD without a relative
> URL.
Sorry, I meant WITH a relative URL.
/Morten
> I'm trying to load an XML file, that references a DTD without a relative
> URL. This renders the error: Could not find file
[quoted text clipped - 11 lines]
> XmlDocument doc = new XmlDocument();
> doc.Load(stream); // This is where it fails
What's wrong with
doc.Load("http://maps1.intergraph.com/wms/ussample/request.asp?SERVICE=WMS&REQUEST=GetCapa
bilities");
> Is there some way I can prevent the DTD checking, or make it read the dtd,
> which is located relative to the XML file?
No, you cannot prevent checking DTD, XmlTextWriter, which is always used
underneath always checks if DTD exists.
You problem is that you are providing XML as stream, so relative URI is
broken. Th easiest way is to provide URL to Load() method. If you need more
control over loading, use XmlTextReader and give him base URI or the XML you
are loading to allow proper URI resolving:
WebRequest myRequest =
WebRequest.Create("http://maps1.intergraph.com/wms/ussample/request.asp?SERVICE=WMS&REQUEST=GetCapa
bilities");
WebResponse myResponse = myRequest.GetResponse();
Stream stream = myResponse.GetResponseStream();
XmlTextReader r = new
XmlTextReader("http://maps1.intergraph.com/wms/ussample/request.asp?SERVICE=WMS&REQUEST=GetCapa
bilities",
stream);
XmlDocument doc = new XmlDocument();
doc.Load(r);

Signature
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel
Morten Nielsen - 09 Oct 2003 11:04 GMT
> What's wrong with
doc.Load("http://maps1.intergraph.com/wms/ussample/request.asp?SERVICE=WMS&R
EQUEST=GetCapabilities");
I need to use a proxy to download data. XmlDocument doesn't have a Proxy
property like WebRequest does.
/Morten
Oleg Tkachenko - 09 Oct 2003 11:11 GMT
> doc.Load("http://maps1.intergraph.com/wms/ussample/request.asp?SERVICE=WMS&R
> EQUEST=GetCapabilities");
>
> I need to use a proxy to download data. XmlDocument doesn't have a Proxy
> property like WebRequest does.
So,
WebRequest myRequest =
WebRequest.Create("http://maps1.intergraph.com/wms/ussample/request.asp?SERVICE=WMS&REQUEST=GetCapa
bilities");
myRequest.Proxy = ...
WebResponse myResponse = myRequest.GetResponse();
Stream stream = myResponse.GetResponseStream();
XmlTextReader r = new
XmlTextReader("http://maps1.intergraph.com/wms/ussample/request.asp?SERVICE=WMS&REQUEST=GetCapa
bilities",
stream);
XmlDocument doc = new XmlDocument();
doc.Load(r);

Signature
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel
Morten Nielsen - 09 Oct 2003 13:51 GMT
Thanks a lot.
It worked perfectly!
/Morten