I parse a big xml document with Sax, I want to stop parsing the document when some condition establish? How to do?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- Illegal to have multiple roots (start tag in epilo
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
Create a specialization of a SAXException and throw it (you don't have to create your own specialization but it means you can specifically catch it yourself and treat other SAXExceptions as actual errors).
I am not aware of a mechanism to abort SAX parsing other than the exception throwing technique outlined by Tom. An alternative is to switch to using the StAX parser (see pull vs push).
I use a boolean variable "
stopParse
" to consume the listeners since i don´t like to usethrow new SAXException()
;Update:
@PanuHaaramo, supossing to have this .xml
the parser to get the "title" value using android SAX must be: