I am parsing an XML file for an Android app I am writing and have noticed that without a leading space the first char is replaced with a blank space.
public void characters(char ch[], int start, int length) { //extends DefaultHandler
if(this.in_mytag || this.in_user_id){
myXMLParser.setExtractedString(new StringBuffer().append(ch).toString());
}
}
I am wanting to use the following format in my XML…
<user_id>123</user_id>
The string that is returned is ” 23″ (with the 1 lost and an empty space in the string).
If I use
<user_id> 123</user_id>
the result is the expected ” 123″. What am I missing here? Or is this typical and I will need to alter my XML file.
All the SAX
characters()method implementations I’ve seen have observed the offset and length parameters.Does this version make any difference?