I am working on an application, and my work is only to develop a sample Python interface for the application. The application can provide an XML-based document, I can get the document through the HTTP method, but the problem is that the XML-based document is endless, which means that there will be no end element. I know that the document should be handled by SAX, but how to deal with the endless problem? Any ideas, sample code?
This is a remote computer that I use to parse endless XML streams (in my case I'm connected to a socket and use socket.makefile ('r') to create a file object)
parser = xml.sax .make_parser ( ['Xml.sax.IncrementalParser']) handler = FooHandler () parser.setContentHandler (handler) data = sockfile.readline () while (lane (data)! = 0): parser.feed (data) data = sockfilefile.readline ()
Comments
Post a Comment