467,891 Members | 1,826 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Ignore DocType

Nat

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.
Nathalie

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
  • viewed: 9131
Share:
6 Replies
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
Nov 12 '05 #2
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

Nov 12 '05 #3
Hi,

Is there a way to ignore the doctype by using ASP technology (not ASP.net) technology?

Thank you very much,

Elvina

---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
Nov 12 '05 #4
Hi,

Is there a way to ignore the doctype by using ASP technology (not ASP.net) technology?

Thank you very much,

Elvina

---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
Nov 12 '05 #5
DotNetJunkies User wrote:
Is there a way to ignore the doctype by using ASP technology (not ASP.net) technology?


Try to turn off validation on parse:

xDoc.validateOnParse = false;
xDoc.Load(....)

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #6
DotNetJunkies User wrote:
Is there a way to ignore the doctype by using ASP technology (not ASP.net) technology?


Try to turn off validation on parse:

xDoc.validateOnParse = false;
xDoc.Load(....)

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by KongHu | last post: by
reply views Thread by Daniel Ng | last post: by
9 posts views Thread by red | last post: by
2 posts views Thread by DartmanX | last post: by
25 posts views Thread by Viken Karaguesian | last post: by
1 post views Thread by KatB | last post: by
reply views Thread by Bill nguyen | last post: by
drhowarddrfine
reply views Thread by drhowarddrfine | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.