remove xml declaration from the generated xml document using java

前端 未结 4 1174
面向向阳花
面向向阳花 2020-12-07 01:03
String root = \"RdbTunnels\";
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilder         


        
4条回答
  •  爱一瞬间的悲伤
    2020-12-07 01:55

    Have you seen OutputKeys as used by Transformer? Specifically OMIT_XML_DECLARATION.

    Note that removing the header is valid in XML 1.0, but you lose character encoding data (among other things) which can be very important.

提交回复
热议问题