Android trimming unwanted trailing whitespaces using XML parser?

397 Views Asked by At

I need to trim the extra white spaces while parsing the content from an XML in android? I'm using regular expression for this for removing the spaces between end tag and start tag My code is:

topicValue.replaceAll(">\\s+<", "><").trim();

But for getting the number bullets for the subtopics, the space is not removed correctly!! Now its appearing like this.. Not in separate line and also white space before the numbers. eg: 1. abcd 2. efgh 3.ijkl

Suggest any idea for this.. Thanks for help!!

1

There are 1 best solutions below

0
On

Got the solution!! Code is:

description.setText(str.replaceAll("(^ )|( $)", ""));

Reference link: Strip Leading and Trailing Spaces From Java String

Thanks for help!!