Java 如何修复org.w3c.dom.ls.LSException:字符'';是无效的XML字符吗?

Java 如何修复org.w3c.dom.ls.LSException:字符'';是无效的XML字符吗?,java,html,xml,Java,Html,Xml,我使用java从文本创建HTML文件,但有一个例外(LSException): 如何修复“org.w3c.dom.ls.LSException:字符“”是无效的XML字符?” 更新:代码 doImplementationRegistry=doImplementationRegistry.newInstance()dominplementals impl=(dominplementals)注册表 LSSerializer writer=impl.createLSSerializer() LSOut

我使用java从文本创建HTML文件,但有一个例外(LSException): 如何修复“org.w3c.dom.ls.LSException:字符“”是无效的XML字符?”

更新:代码

doImplementationRegistry=doImplementationRegistry.newInstance()
dominplementals impl=(dominplementals)注册表
LSSerializer writer=impl.createLSSerializer()
LSOutput output=impl.createLSOutput()
output.setEncoding(StandardCharsets.UTF_8.name())
writer.getDomConfig().setParameter(“格式漂亮打印”,true)
output.setCharacterStream(outputStream)
processDocument(doc)

writer.write(getDocument(),输出)

也许您可以显示您的代码?共享该xml行,错误在哪里?很可能您的HTML文件不是有效的xhtml/xml文件。请确保您使用的是ASCII引号,而不是Microsoft引号。确保引号出现在允许的地方。同意@MiyaG的观点,我们需要看到您试图解析的文档,或者至少是其中失败的部分,说得更多。