Java 如何修复org.w3c.dom.ls.LSException:字符'';是无效的XML字符吗?
我使用java从文本创建HTML文件,但有一个例外(LSException): 如何修复“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
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的观点,我们需要看到您试图解析的文档,或者至少是其中失败的部分,说得更多。