
We have a C application that uses expat to parse a XML stream (XMPP). The stream only terminates when the connection closes and we need to process (and respond) to it while its open, so a DOM parser would not work. Inside the <stream/> (root element) are "stanzas", elements at depth=1 which are generally short and easy to parse, so its desirable to pass each stanza to a DOM tree for further processing in Python. We can do this with cElementTree due to the exposed expat handlers, but I have not yet seen anything in lxml's C api which would suggest that its capable of this. Is it possible to construct and populate a lxml.etree externally using startElement, endElement, etc calls in a manner which is compatible with libxslt? Its also a bit frustrating that lxml's C headers are not installed to the system (and thus unpackaged on both Gentoo and Debian/Ubuntu).