How to remove the white spaces between tags in XML

后端 未结 7 919
太阳男子
太阳男子 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:25

    None of the other answers worked for me. I had to use the below code, to remove both additional whitespaces and new lines.

    xmlString.trim().replace("\n", "").replaceAll("( *)<", "<")
    

提交回复
热议问题