簡體   English   中英

org.xml.sax.SAXParseException:元素的內容必須由格式正確的字符數據或標記組成

[英]org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup

我在 Java XML Parser 中執行此操作,然后在解析 xml 文件時出現此錯誤...

[致命錯誤] jira.xml:192:64:元素的內容必須由格式正確的字符數據或標記組成。 org.xml.sax.SAXParseException:元素的內容必須由格式正確的字符數據或標記組成。 在 com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) 在 com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) 在 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>
&lt;< inside &amp;& the description tag &lt;<
</DESCRIPTION>
</DATA_RECORD>

臨時解決方案-> 我發現 XML 規范<不應該在 xml 中,所以我將使用contents.toString().replaceAll("&lt;<", "&lt;").replaceAll("&amp;&", "&amp;")

對我來說,這行似乎有編碼問題。

&lt;< inside &amp;& the description tag &lt;<

應該是

&lt;&lt; inside &amp;&amp; the description tag &lt;&lt;

或它應該是

&lt; inside &amp; the description tag &lt;

我為 JS 使用了 XML 注釋標記

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM