Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm doing it in Java XML Parser, then I got this error when parsing an xml file...

[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)

Any clue what could be the problem? Thank you.

Here is the code used -> http://s29.postimg.org/tjbzvsn3b/xmlreader.jpg

Here is my jira.xml ->

<?xml version="1.0" ?>
<DATA_RECORD>
<DESCRIPTION>
&lt;< inside &amp;& the description tag &lt;<
</DESCRIPTION>
</DATA_RECORD>

Temporary solution -> I figured out that XML Norms < should not be in the xml, so I will use contents.toString().replaceAll("&lt;<", "&lt;").replaceAll("&amp;&", "&amp;")

like image 530
jhed Avatar asked Aug 01 '14 02:08

jhed


1 Answers

To me it looks like you have an encoding problem with this line.

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

should either be

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

or it should be

&lt; inside &amp; the description tag &lt;
like image 152
dave Avatar answered Oct 30 '22 12:10

dave