Re: ElementTree should parse string and file in the same way
- From: Stefan Behnel <stefan.behnel-n05pAM@xxxxxx>
- Date: Mon, 31 Dec 2007 09:12:43 +0100
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
.
- References:
- ElementTree should parse string and file in teh same way
- From: Peter Pei
- ElementTree should parse string and file in teh same way
- Prev by Date: desktop computer
- Next by Date: Is there a string function to trim all non-ascii characters out of a string
- Previous by thread: Re: ElementTree should parse string and file in teh same way
- Next by thread: Re: how to connect to a remote machine using python........
- Index(es):
Relevant Pages
|