473,326 Members | 2,133 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,326 software developers and data experts.

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
6 9608
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: KongHu | last post by:
--
0
by: Daniel Ng | last post by:
Hello, This question has been asked before, unfortunately, no answer has been posted. I want to parse an XML file and ignore the <!DOCTYPE ..> tag. Does anyone know the answer? Daniel
9
by: red | last post by:
If I have <span>text</span> <br> and then some text isn't there sopposed to be a line break between the span and the text ? Why do browsers ignore the <br> ?
2
by: DartmanX | last post by:
I doubt this is possible, but I want to ask, just in case it is. I have a project going using Google Maps. This project spits out an HTML page template for people to post to their website and...
25
by: Viken Karaguesian | last post by:
Hello all, I'm somewhat of a newbie to webscripting. I've made a couple of websites in the past with WYSIWYG software, but now I'm much more interested in manual scripting. I have some...
1
by: KatB | last post by:
Hi, I'm using the transform class for an xml document. However, all my documents are created by authoring tool and contain a DTD declaration: <!DOCTYPE jabil SYSTEM "C:\Program...
0
by: Bill nguyen | last post by:
I'm using ReadXML to read xml files. These files contain the declaration <!DOCTYPE DTN_ENERGY_XML_PRICE_FORMAT SYSTEM "NPD1_XML.DTD"> that I don't have access to (and don't need to) that causes an...
0
drhowarddrfine
by: drhowarddrfine | last post by:
The Doctype or DTD Many coders get confused by all the talk of doctypes and how they affect browsers and the display of their web pages. This article will get right to the point about doctypes...
0
by: samz | last post by:
Hello, Here is a simple PHP recursive file list (with interactive and visual FX) Sam's Files http://acc.jexiste.ch/JPN/RecurciveDIR12.RAR 1. How to ignore/avoid empty folders in this PHP script...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.