File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes SAX Parser How to break once i get required values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "SAX Parser How to break once i get required values" Watch "SAX Parser How to break once i get required values" New topic
Author

SAX Parser How to break once i get required values

Sanjay Ra
Ranch Hand

Joined: Nov 05, 2004
Posts: 31
Hi,

I am using a SAX Parser (xerces) .
I dont need to parse the entire XML and would like to stop parsing once i get certain values.
How could i do this?

thanks
Sanjay
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
You could just throw some custom RuntimeException and catch it outside the call to parse(). Certainly not too pretty but at least it works.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Sanjay Ra
Ranch Hand

Joined: Nov 05, 2004
Posts: 31
is this the only way ?

thanks!
Sanjay
 
Consider Paul's rocket mass heater.
 
subject: SAX Parser How to break once i get required values
 
Similar Threads
Parsing XML string using Java Program
reading xml data
what is dtd and dft?
How to get XML file name ?
how sax parser is installed or JAR FILE OF SAX API