This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
I am subclassing the DefaultHandler class and overriding the methods like: characters(char ch, int start, int length) endElement(String uri, String localName, String qName) and others...
While debugging though I found out that for one element it just fetches the data partially... i.e if <element2> has data data2 the characters() method just gets da and gets the remaining data (ta2) in the next iteration for the same element which is really weird.
This situation happens exactly at the same place for the same element. Are there any limitations? Or am I doing something wrong?
Incase the information is not clear or insufficient for you to help me, please let me know and I will give more information.
Joined: Oct 31, 2005
I was able find out the real issue. Actually the characters() method will not return the complete data between the tags at one shot, I think it depends on some buffer size, I don't know the exact reason.
So, till we encounter the endElement() method, we have to store the data given by the characters() method in our own buffer for that current element.
No thats the only way. SAX specifies that it does not need to return full element content in one characters() call. You need to use a string buffer and append the data from multiple character() calls until you get the endElement() call, as you said.