I'm using XmlPullParser to parse some custom XML. I open the XML file like this...
XmlPullParser xpp = activity.getResources().getXml(R.xml.myXML);
And later I read the following XML node
<L> ####</L>
using the code
String str = "";
if( xpp.next() == XmlPullParser.TEXT )
str = xpp.getText();
return str;
Instead of returning
' ####'
I get
' ####'
(single quotes added by me for clarity.) NOTE The missing leading space.
It appears getText is stripping the leading space? When the XML doesn't contain a leading space, my code works as expected.
I can't find any property of XMLPullParser that allows me to tell it to keep all whitespace. Nor can I change the XML to add double quotes around the text with leading whitespace.