Skip to content Skip to sidebar Skip to footer

How To Implement Characters Method Using Saxparser On Android

I am parsing xml using the SAXParser and want to know if this is the right way to implement the characters method. Assume there's a class-level String variable named elementValue a

Solution 1:

Yes, you need to append because there is no guarantee that the chunk of data read will contain all of the element text.

The start position is given and needs to be used because the other characters in the array can be junk.

However, you should use a StringBuffer instead, and call its' append() method, like so:

publicvoidcharacters(char[] ch, int start, int length){
  yourStringBuffer.append(ch, start, length);
}

Post a Comment for "How To Implement Characters Method Using Saxparser On Android"