469,612 Members | 2,665 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,612 developers. It's quick & easy.

XmlDocument.Load(file) without entity resolving?

I need to merge several XML files into one large. All of them has a DOCTYPE
tag, but the SYSTEM identifier points to a DTD that doesn't exist. (I use
the PUBLIC identifier with catalog files, so the SYSTEM identifiers has no
purpose in my application.)

Anyway, when I load each document, using XmlDocument.Load(file), I get a
FileNotFoundException, because of the DTD pointer in the SYSTEM identifier.
I'd rather skip all the entity resolving and just read the well-formed XML.
Is there a simple way to do this?

Here's the code, in C#:

// Make a DOM Document of the included file
XmlDocument d = new XmlDocument();
d.Load(file);

// Import the node
XmlNode n = xmlDoc.ImportNode(d.DocumentElement, true);
xmlDoc.DocumentElement.AppendChild(n);

Thanks,

Gustaf
Nov 12 '05 #1
2 6650
Gustaf Liljegren wrote:
I need to merge several XML files into one large. All of them has a DOCTYPE
tag, but the SYSTEM identifier points to a DTD that doesn't exist. (I use
the PUBLIC identifier with catalog files, so the SYSTEM identifiers has no
purpose in my application.)

Anyway, when I load each document, using XmlDocument.Load(file), I get a
FileNotFoundException, because of the DTD pointer in the SYSTEM identifier.
I'd rather skip all the entity resolving and just read the well-formed XML.
Is there a simple way to do this?

Here's the code, in C#:

// Make a DOM Document of the included file
XmlDocument d = new XmlDocument();


Try
d.XmlResolver = null;

PS. You may want take a look at XInclude when it comes to combining XML
docs.
--
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog

Nov 12 '05 #2
Oleg Tkachenko <oleg@NO!SPAM!PLEASEtkachenko.com> wrote:
d.XmlResolver = null;
Yes! Thank you!
PS. You may want take a look at XInclude when it comes to combining
XML docs.


It's XInclude I'm trying to implement. Maybe I should stop wasting time and
look for a finished implementation, but it's fun. :o)

Gustaf
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by CPD | last post: by
2 posts views Thread by John Bailey | last post: by
2 posts views Thread by antonyliu2002 | last post: by
1 post views Thread by Steve Wofford | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.