Oct 25, 2011

SAXParseException

I have experienced SAXParseException occurred while parsing a document feed retrieved from https://docs.google.com/. This happened on Nokia E71 device, while an emulator parsed the feed successfully. There was no any reason to throw this exception, because the feed XML document was well-formatted and valid.

The problem has been solved by ignoring any fatal errors. Here is a code:

public class DocsFeed extends DefaultHandler {
    public void startElement(String uri, String localName, String qName, Attributes attrs) {
        ...
    }

    public void endElement(String uri, String localName, String qName) {
        ...
    }

    public void characters(char[] ch, int start, int length) {
        ...
    }

    public void fatalError(SAXParseException ex) {
        /* don't do anything, just ignore it */
    }
}

This solutions allowed me to successfully parse XML document. Once more notice please that XML document was valid. Probably, this is a bug in SAX parser implementation by Nokia.

0 comments:

Post a Comment