How to remove encoding=“UTF-8” standalone=“no” from xml Document object in Java

梦想与她 提交于 2019-12-04 04:39:18

I think there is no legal way to exclude theese attributes from generation. But after it's generated you can use XSLT to remove this.

I think this is a good way.

Why do you need to remove an encoding? But..

doc.setXmlStandalone(true);

will erase standalone="no"

Nan chen
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");

This would resolve your issue, verified at JDK 6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!