473,396 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Loading XML with missing DTD

I'm trying to load an XML file, that references a DTD without a relative
URL. This renders the error: Could not find file
"C:\WINNT\system32\capabilities_1_1_0.dtd".

Here's the XML I'm loading:
http://maps1.intergraph.com/wms/ussa...etCapabilities
Notice the DTD reference at the second line:
<!DOCTYPE WMT_MS_Capabilities SYSTEM "capabilities_1_1_0.dtd" [

What I try to do:
----------------------------------
WebResponse myResponse = myRequest.GetResponse();
Stream stream = myResponse.GetResponseStream();
XmlDocument doc = new XmlDocument();
doc.Load(stream); // This is where it fails
----------------------------------

The code works fine when no DTD is specified.

Is there some way I can prevent the DTD checking, or make it read the dtd,
which is located relative to the XML file?

Any help is appreciated.

Regards
/Morten Nielsen
Email: http://www.iter.dk/contact.aspx
Nov 11 '05 #1
5 5877
> I'm trying to load an XML file, that references a DTD without a relative
URL.


Sorry, I meant WITH a relative URL.

/Morten
Nov 11 '05 #2
Morten Nielsen wrote:
I'm trying to load an XML file, that references a DTD without a relative
URL. This renders the error: Could not find file
"C:\WINNT\system32\capabilities_1_1_0.dtd".

Here's the XML I'm loading:
http://maps1.intergraph.com/wms/ussa...etCapabilities
Notice the DTD reference at the second line:
<!DOCTYPE WMT_MS_Capabilities SYSTEM "capabilities_1_1_0.dtd" [

What I try to do:
----------------------------------
WebResponse myResponse = myRequest.GetResponse();
Stream stream = myResponse.GetResponseStream();
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=GetCapabilities");

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=GetCapabilities");
WebResponse myResponse = myRequest.GetResponse();
Stream stream = myResponse.GetResponseStream();
XmlTextReader r = new
XmlTextReader("http://maps1.intergraph.com/wms/ussample/request.asp?SERVICE=WMS&REQUEST=GetCapabilities",
stream);
XmlDocument doc = new XmlDocument();
doc.Load(r);
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #3
> 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
Nov 11 '05 #4
Morten Nielsen wrote:
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=GetCapabilities");
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=GetCapabilities",
stream);
XmlDocument doc = new XmlDocument();
doc.Load(r);

--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #5
Thanks a lot.
It worked perfectly!

/Morten
Nov 11 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Joe Johnson | last post by:
Greetings, I just did a fresh install of Solaris 10 on Sparc. The OS ships with perl_5.8.4. When I run some of my scripts that run fine on Linux, I get this: IO::Seekable::getpos missing at...
6
by: Ed | last post by:
I first noticed this in my own app. Images would show up missing randomly on IE 6.0.2800.1106 on Windows 2000 server. I then was able to repro this problem on Microsoft's website!!! The page I...
0
by: Parag Joshi | last post by:
hi, I am facing a wierd problem with dyanamic class loading. I have a namespace called ETS.DAO which contains my Data Access Object classes. All these classes implement a common interface which...
4
by: tnhoe | last post by:
Hi, how do i code such that all gifs are loaded without missing any one of them ? I always get missing few gifs when the page loading with 30 gifs. I use IE6 to browse many <a...
5
by: Kurt Bauer | last post by:
I have an ASP group calendar application which pulls calendar data from Exchange via webdav into an XML string. I then loop the XML nodes to populate a collection of appointments. Finally I use...
1
by: Martin Schneider | last post by:
Hi! I created a database form with a simple Form_Load procedure and a simple Form_resize procedure. Both work fine on one machine. On a second machine I get a "Error loading DLL" on these...
6
by: snazzy | last post by:
I have a problem where using innerHTML to rewrite a DIV or removeChild to kill a DIV that either of them, if excuted before the page is done loading will stop the page in its tracks. ...
1
by: Anders Borum | last post by:
Hello! I was wondering if I am the only person missing the option of outputting a single dll for a website (just like the good old v1.1 compilation model)? What I'm looking for is the ASP.NET...
8
by: =?Utf-8?B?TWFyaw==?= | last post by:
We've got a wierd failure happening on just one machine. One part of our product uses a 3rd party search implementation (dtSearch). DtSearch has a native core (dten600.dll), late-bound, and a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.