XML Document to String

前端 未结 3 1394
余生分开走
余生分开走 2020-11-27 02:44

What\'s the simplest way to get the String representation of a XML Document (org.w3c.dom.Document)? That is all nodes will be on a single line.

As an ex

3条回答
  •  情深已故
    2020-11-27 03:27

    First you need to get rid of all newline characters in all your text nodes. Then you can use an identity transform to output your DOM tree. Look at the javadoc for TransformerFactory#newTransformer().

提交回复
热议问题