|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How to ask a SAX parser to stop firing events ? (whithout using Exce
Sebastien Sahuc <ssahuc@i...> writes:
> Suppose the Parser has fed your application with half of the XML
> document and you don't need to go further. How can you gently say to
> the parser you've done with it ? I would like not to send an
> Exception, because at runtime it is too time consuming and not really
> nice.
In Java, an exception is the *normal* way to do this. Here's an
example (for SAX1):
public class DoneParsingException extends SAXException
{
}
and then
public void startElement (String name, AttributeList atts)
{
if (iHaveSeenEnough) {
throw new DoneParsingException();
}
}
and then
try {
parse(myDocument);
} catch (DoneParsingException e) {
System.out.println("Parsing finished OK");
} catch (SAXException e) {
System.out.println("Something went wrong");
}
I'm not sure what is time consuming about this.
All the best,
David
--
David Megginson david@m...
http://www.megginson.com/
***************************************************************************
This is xml-dev, the mailing list for XML developers.
To unsubscribe, mailto:majordomo@x...&BODY=unsubscribe%20xml-dev
List archives are available at http://xml.org/archives/xml-dev/
***************************************************************************
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|
|||||||||

Cart








