Java/DOM: Get the XML content of a node

后端 未结 6 2198
无人及你
无人及你 2021-01-05 07:44

I am parsing a XML file in Java using the W3C DOM. I am stuck at a specific problem, I can\'t figure out how to get the whole inner XML of a node.

The node looks lik

6条回答
  •  长发绾君心
    2021-01-05 08:27

    To remove unneccesary tags probably such code can be used:

    DOMConfiguration config = serializer.getDomConfig(); config.setParameter("canonical-form", true);

    But it will not always work, because "canonical-form=true" is optional

提交回复
热议问题