解析xml文件的奇怪问题
有一个xml文件,使用
org.xml.sax.XMLReader和org.dom4j.io.SAXReader解析结果不同,是什么原因?
try {
XMLReader parser = XMLReaderFactory.createXMLReader();
parser.parse
(new InputSource(new java.io.FileReader("E:\\office\\doc\\java_doc\\Html2XLIFF\\lib\\content.zh123.xml")));
System.out.println("XMLReader ok");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
SAXReader parser = new SAXReader();
parser.read(new File
("E:\\office\\doc\\java_doc\\Html2XLIFF\\lib\\content.zh123.xml"));
System.out.println("SAXReader ok");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
执行上面的代码,结果得到:
[Fatal Error] :2:27095: The element type "text:p" must be terminated by the matching end-tag "</text:p>".
org.xml.sax.SAXParseException: The element type "text:p" must be terminated by the matching end-tag "</text:p>".
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at test.Test.main(Test.java:48)
SAXReader ok
很奇怪,是不是org.xml.sax.XMLReader有bug啊?
csdn不支持附件,我把xml文件放网盘上面了。
http://dl-web.dropbox.com/u/5677556/content.zh__.xml