How to Convert IO Stream to XML Document

Stefan Behnel stefan_ml at behnel.de
Sat Sep 11 01:09:56 EDT 2010


jakecjacobson, 10.09.2010 18:20:
> 	response = urllib2.urlopen(request)
> 	pageguts = response.read()
> 	xmldoc = minidom.parse(pageguts)

Check the minidom docs, there's a parseString() function that does what it 
says.

Also, don't forget to take a look at xml.etree.ElementTree. Depending on 
what you want to do with the XML result, it'll likely be easier to use and 
faster than minidom. The function there is called fromstring(), just in case ;)

Stefan




More information about the Python-list mailing list