[Python-ideas] ElementTree iterparse string
Eli Bendersky
eliben at gmail.com
Wed Aug 7 14:50:01 CEST 2013
On Tue, Aug 6, 2013 at 6:52 PM, Ryan <rymg19 at gmail.com> wrote:
> ElementTree iterparse only works with file names or file objects. What if
> there was an iterparse for strings? Like iterparsestring or iterfromstring
> or iterstring, etc. Even though the string is stored in memory, storing the
> entire tree along with the string is a major minus, especially since a
> string takes less memory than an ElementTree instance or a root element.
>
>
Hi Ryan,
1) This question is more suitable for python-list@ or Stack Overflow
2) In addition to Antoine's suggestion, note that ET takes file-like
objects everywhere, which means you can use StringIO. Look at the tests in
Lib/test/test_xml_etree.py for some examples. This is a common idiom in
Python programming.
Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130807/3349cd8b/attachment.html>
More information about the Python-ideas
mailing list