Is there a way to call a quit() function on an SAXParser or XMLReader?
The XML document is only updated every day or so, and I only want the full document to be read if the element has changed.
Within my Default Handler:
@Override
public void endElement(String uri, String localName, String qName)
throws SAXException {
if (localName.equals("pubDate")) {
if (currentValue.equals(mPreviousPubDateValue)) {
//exit parsing
}
} else {
//keep on parsing
}
}
The XML document is fairly large, and I'd like to be able to just quit it. DefaultHandler doesn't have any built-ins for stopping the parsing. I could also pass in a reference to the XMLReader, but it also doesn't have a method for stopping itself.
Thanks!
you can throw the SAXException
to stop parsing
you can use a subclass of it to ensure the parsing failed because of your decision and not a random parse exception