Replacing XML node via Java

后端 未结 2 827
情书的邮戳
情书的邮戳 2021-01-18 17:08

I wan to replace a node in XML document with another and as a consequence replace all it\'s children with other content. Following code should work, but for an unknown reaso

2条回答
  •  清酒与你
    2021-01-18 17:47

    Easy way to do is using regular expression.

    String payload= payload.replaceAll("([^<]*)", "NODATA");
    

    This will make sure all the payload nodes contents are replaced with NODATA

提交回复
热议问题