The string "--" is not permitted, java project
14,848
Without further knowing your code:
There error is as you were told. Somewhere in your XML sheet, you have a comment, which includes a --
in it. For example something like this:
<root>
<!-- my comment with -- in it -->
</root>
This is not a well formed XML. Within a comment --
is not allowed. The parser will have problems to detect the end of the comment then.
Author by
user1918246
Updated on September 09, 2022Comments
-
user1918246 over 1 year
Possible Duplicate:
Cure for ‘The string “--” is not permitted within comments.’ exception?I have a Java project to parse and edit XML files. When I try to run the project I get the following log message:
The string "--" is not permitted within comments. Exception in thread "main" org.xml.sax.SAXParseException: The string "--" is not permitted within comments. at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:246) ...
How can I resolve it?
-
xoned over 11 yearsMay you can explain why it's difficult for the parser? I mean "-->" defines the end of the comment. So why is the parser not just ignoring the "--" and looking further?
-
user1918246 over 11 yearsDocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); docFactory.setIgnoringComments(true); docFactory.setValidating(false); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); doc = docBuilder.parse(file);
-
vishal_aim over 11 years@Timo +1 for comment, I just searched and found that they kept it like this to remain compatible with SGML
-
Jörn Horstmann over 11 years@Timo: Because its specified that way for compatibility with SGML: w3.org/TR/xml/#sec-comments
-
user1918246 over 11 yearsthere is no way to resolve this?