java 字符串“--”是不允许的,java项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13968861/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 14:36:09  来源:igfitidea点击:

The string "--" is not permitted, java project

javaxmlstringparsing

提问by user1918246

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:

我有一个 Java 项目来解析和编辑 XML 文件。当我尝试运行该项目时,我收到以下日志消息:

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?

我该如何解决?

回答by Sirko

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:

正如你所说的那样有错误。在您的 XML 表中的某处,您有一个注释,其中包含一个--。例如这样的事情:

<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.

这不是一个格式良好的 XML。--不允许在评论中。解析器将在检测注释结束时遇到问题。