views:

445

answers:

1

Hi,

I am using SAX Parser to parser XML file on Blackberry platform.

Some XML tags contains exrta spaces and newline characters. How to remove this unnecessary whitespace characters while parsing XML file.

Any help would be appreciated.(I tried to use Trim() function but still it doesn't remove extra whitespaces.)

Thanks,
Jim.

+2  A: 

Try str.replace("\n","").replace("\r","").trim();

igor
I think you've gotten it right, and the OP is complaining about element content rather than the elements themselves. Incidentally, you don't need to replace "\r"; a compliant parser should normalize newlines.
kdgregory
if it's about element inner text then this should be used in characters() method, else (ex to change Attributes) use in startElement()
Max Gontar