Changing node name of xml-node with Java

后端 未结 5 1540
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-30 05:42

I have following scenario: I have a XML-Document, e.g. like this



    

        
5条回答
  •  一整个雨季
    2020-12-30 06:24

    As you did get the attributes:

    NamedNodeMap nnm = nodes.item(i).getAttributes();
    

    and you added these attributes to the new element,

    You should get the children of nodes.item(i) and set them in the new node.

    You can use for ex.:

    neu.addContent(nodes.item(i).getChildren());
    

提交回复
热议问题