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
This is the regular expression (?:>)(\s*)<
When you use it in the code for Java use
"(?:>)(\\s*)<" and replace with "><"
String xmlString = " Tove Jani Reminder Today Don't forget me this weekend! ";
String str = xmlString.replaceAll("(?:>)(\\s*)<", "><");
This will remove the spaces between the tags and maintain the spaces for the value.
Input:
Tove
Jani
Reminder Today
Don't forget me this weekend!
Output:
Tove Jani Reminder Today Don't forget me this weekend!