ElementTree should parse string and file in the same way

Peter Pei yantao at telus.com
Tue Jan 1 02:55:57 CET 2008


To be preise, XPath is not fully supported. Don't be a smart asshole.
=====================================================================
"Stefan Behnel" <stefan.behnel-n05pAM at web.de> wrote in message 
news:4778A47B.9020201 at web.de...
> Peter Pei wrote:
>> One bad design about elementtree is that it has different ways parsing a
>> string and a file, even worse they return different objects:
>> 1) When you parse a file, you can simply call parse, which returns a
>> elementtree, on which you can then apply xpath;
>
> ElementTree doesn't support XPath. In case you mean the simpler 
> ElementPath
> language that is supported by the find*() methods, I do not see a reason 
> why
> you can't use it on elements.
>
>
>> 2) To parse a string (xml section), you can call XML or fromstring, but
>> both return element instead of elementtree. This alone is bad. To make
>> it worse, you have to create an elementtree from this element before you
>> can utilize xpath.
>
> a) how hard is it to write a wrapper function around fromstring() that 
> wraps
> the result Element in an ElementTree object and returns it?
>
> b) the same as above applies: I can't see the problem you are talking 
> about.
>
> Stefan 




More information about the Python-list mailing list