[XML-SIG] python xml parser

Chris Herborth chrish at cryptocard.com
Wed Mar 3 08:26:26 EST 2004

J. Xu wrote:

> How can I pass stdout of processes, or output stream of network channels 
> (like ssh) to a python xml parser (either through DOM or SAX) so that 
> xml can be used as the communication tool among different components of 
> the software? I think the standard python xml reader expects a file-like 
>  object or string as the input, but not sure if it can take a stream. 
> Any suggestions are highly appreciated.

If you're not passing large amounts of data around, httplib looks pretty 
easy to hook up:

# Pretty much straight from the Library Reference:

import httplib
conn = httplib.HTTPConnection("www.python.org")
conn.request("GET", "/index.html")
r1 = conn.getresponse()
data1 = r1.read()

# pass data1 to an XML processor's parseString() or similar method
# exercise for the reader ;-)


Chris Herborth                                     chrish at cryptocard.com
Documentation Overlord, CRYPTOCard Corp.      http://www.cryptocard.com/
Never send a monster to do the work of an evil scientist.
Postatem obscuri lateris nescitis.

More information about the XML-SIG mailing list