re: Stopping XML parsing in mid-stream?
David Megginson <[email protected]>
| Newsgroups | gmane.text.xml.sax.general |
|---|---|
| Message-ID | <[email protected]> |
Michael Chang writes:
> > > So, essentially, I need a way to get parse() to return after it has seen a
> > > closing root node.
> >
> > Throw an exception -- that's the way SAX was designed to work:
> >
> > public class StopParsingException extends SAXException
> > {
> > ...
> > }
>
> Except that, when reading from my InputStream, no exceptions are
> ever thrown; parse() just keeps on reading and reading and reading.
> An exception *is* thrown once I forcefully close the connection on
> the server end, but that's obviously not a workable solution :)
I'm not sure I understand -- you're the one who will have to throw the
exception, in your ContentHandler.endElement() method. If that never
gets called, then your SAX parser might be doing a lot of
forward-buffering -- that's a separate, implementation-specific
problem, and might be solvable by switching to a different SAX parser.
All the best,
David
--
David Megginson, [email protected], http://www.megginson.com/
-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
List: [email protected]
See: http://www.saxproject.org
https://lists.sourceforge.net/lists/listinfo/sax-users