简体   繁体   中英

java XML dtd, sax parser

I've an xml document that has the following

<!DOCTYPE TRACE PUBLIC "trace.dtd" "trace.dtd">

after the first line

<?xml version="1.0" encoding="UTF-8"?>

When I parse it using SAX xml parser, I get the following error...

at javax.xml.parsers.SAXParser.parse(Unknown Source)
java.io.FileNotFoundException: F:\<BLAH>\trace.dtd (The system cannot find the file specified)

Any ideas how to bypass this tag in order to parse the xml successfully?

Well according to this

SAXParser throws FileNotFoundException despite not being given a file to parse

it worked just fine

factory.setValidating(false);
factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM