简体   繁体   English

Java XML dtd,sax解析器

[英]java XML dtd, sax parser

I've an xml document that has the following 我有一个具有以下内容的xml文档

<!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... 当我使用SAX xml解析器解析它时,出现以下错误...

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? 任何想法如何绕过此标记以成功解析xml?

Well according to this 好吧据此

SAXParser throws FileNotFoundException despite not being given a file to parse 尽管未提供要解析的文件,但SAXParser抛出FileNotFoundException

it worked just fine 它工作得很好

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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