How to remove the white spaces between tags in XML

后端 未结 7 929
太阳男子
太阳男子 2020-12-06 18:00

I created an XML document using Java in my android application. I have to call a web service in my application and pass this XML as an argument there. But my problem is ther

7条回答
  •  北荒
    北荒 (楼主)
    2020-12-06 18:36

    Of course, it depends on your XML itself. However, you could try using regular expressions.

    As an example:

    yourXmlAsString.replaceAll(">[\\s\r\n]*<", "><");
    

    Would remove all whitespace between every XML element.

提交回复
热议问题