re: Stopping XML parsing in mid-stream?

David Megginson <[email protected]>
Newsgroups gmane.text.xml.sax.general
Message-ID <[email protected]>
Michael Chang writes:

 > I've got a problem.  Here's the situation:  My application uses an 
 > SSLSocket to read XML data from a server that sends a new XML document (?) 
 > once per second.  By "XML document," I mean that an entirely
 > new "<?xml version='1.0' ?><nodes>.....</nodes>" chunk is sent to my 
 > client application once per second.  The problem that I'm having is that, 
 > when I hand my InputStream object to my SAXParser.parse() method, parse() 
 > never returns.  The only way I can get it to return is if I tell the 
 > server to send only one chunk and then close the connection.  From this, I 
 > assume that parse() returns because it has seen an EOF (End Of File), 
 > though I might be wrong.
 > 
 > 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
  {
    ...
  }

Exceptions are useful for much more than just error conditions.


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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.