aspose file tools*
The moose likes XML and Related Technologies and the fly likes Parsing an xml File with DOMParser without a DTD ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Parsing an xml File with DOMParser without a DTD ?" Watch "Parsing an xml File with DOMParser without a DTD ?" New topic
Author

Parsing an xml File with DOMParser without a DTD ?

Christoph Ehret
Greenhorn

Joined: Dec 30, 2002
Posts: 12
Hi,
I am parsing an XML File using DOMParser from Xerces; I use

It seems that when it cannot find the DTD specified in the xml file xmlDocument , it throws an IOException. So how can I make it work without a DTD ?
Thanks
Chris
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
If you'd acquire a parser object through a javax.xml.parsers.DocumentBuilderFactory, you could say factory.setValidating(false).


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
Or you can set a variety of features that may meet your needs. That way you don't have to switch back to the DocumentBuilder if you feel like keeping with the DOMParser, or have a need to keep with it.
Christoph Ehret
Greenhorn

Joined: Dec 30, 2002
Posts: 12
Thanks a lot. Setting the feature did it . Thanks .
Chris
[ August 25, 2003: Message edited by: Christoph Ehret ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Parsing an xml File with DOMParser without a DTD ?