Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / June 2004

Tip: Looking for answers? Try searching our database.

Ignore DocType

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nat - 14 Apr 2004 10:48 GMT
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
Oleg Tkachenko [MVP] - 14 Apr 2004 12:10 GMT
> 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.

Signature

Oleg Tkachenko [XML MVP, XmlInsider]
http://blog.tkachenko.com

Tejal Joshi \(MSFT\) - 16 Apr 2004 02:09 GMT
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/default.asp?url=/library/en-us/cpguide/html/cp
conResolvingExternalResources.asp


Thanks,
Tejal.

Signature

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.

> > 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
[quoted text clipped - 8 lines]
> teh DTD, that local copy can be even a dummy one, as XmlTextReader only
> checks DTD exists and is well-formed.
DotNetJunkies User - 22 Jun 2004 20:48 GMT
Hi,

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

Thank you very much,

Elvina

---
Oleg Tkachenko [MVP] - 23 Jun 2004 10:37 GMT
> 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(....)

Signature

Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.