Skip to content Skip to sidebar Skip to footer

Android: Handler Returns Empty String Parsing Xml With Sax Parser

I have been trying to use the SAX parser on Android to display some xml that is the result of a query to a DB. I get the right answer from the DB, but when I want to parse the xml

Solution 1:

The characters method can get called multiple times while inside a tag, especially if the element value contains whitespace.

You might be able to see this happening in that Logcat call by multiple lines being printed.

From the documentation:

The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity so that the Locator provides useful information.

Rather than using setExtractedString, you should append to the string that's being built up, possibly using a StringBuilder.

See the accepted answer here.

Post a Comment for "Android: Handler Returns Empty String Parsing Xml With Sax Parser"