我在 Java XML Parser 中执行此操作,然后在解析 xml 文件时出现此错误...
[Fatal Error] jira.xml:192:64: The content of elements must consist of well-formed character data or markup. org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup. at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at javax.xml.parsers.DocumentBuilder.parse(Unknown Source) at com.icomteq.ReadXMLFile.main(ReadXMLFile.java:20)
任何线索可能是什么问题?谢谢。
这里是使用的代码 -> http://s29.postimg.org/tjbzvsn3b/xmlreader.jpg
这是我的 jira.xml ->
<?xml version="1.0" ?>
<DATA_RECORD>
<DESCRIPTION>
<< inside && the description tag <<
</DESCRIPTION>
</DATA_RECORD>
临时解决方案 ->
我发现 XML 规范 <
不应该在 xml 中,所以我将使用 contents.toString().replaceAll("<<", "<").replaceAll("&&", "&")
最佳答案
在我看来,您对这一行的编码有问题。
<< inside && the description tag <<
应该是
<<里面 &&描述标签 <<
或者应该是
< inside & the description tag <
关于java - org.xml.sax.SAXParseException : The content of elements must consist of well-formed character data or markup,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25072146/