Skip to content

Instantly share code, notes, and snippets.

@gelim
Created October 21, 2010 17:25
Show Gist options
  • Save gelim/638905 to your computer and use it in GitHub Desktop.
Save gelim/638905 to your computer and use it in GitHub Desktop.
lxml.etree and StrinIO strangeness
import StringIO, lxml.etree
xmldata="<root>data</root>"
buffer=StringIO.StringIO(xmldata)
for event, element in lxml.etree.iterparse(buffer):
print "%s %s %s" % (event, element.tag, element.text)
buffer=StringIO.StringIO()
buffer.write(xmldata)
for event, element in lxml.etree.iterparse(buffer):
print "%s %s %s" % (event, element.tag, element.text)
buffer.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment