effbot ElementTree question

Fredrik Lundh fredrik at pythonware.com
Wed Dec 15 08:29:12 CET 2004

<dayzman at hotmail.com> wrote:

> Is anyone here familiar with ElementTree by effbot?
> With <html><body>hello</body></html> how is "hello" stored in the
> element tree? Which node is it under? Similarly, with:
> foo <a href = "blah"> blah </a> bar, how is bar stored? Which node is
> it in?

reposting the reply I just posted to the discussion board where you
asked the same question:

in the body case, the "hello" text ends up in the 'text' attribute of the "body"
node (in HTML/CSS terminology, this is known as an "anonymous block").

in the other case, the trailing text is stored in the 'tail' attribute of the
preceeding element ("a" in this case); see:


for details on how ElementTree deals with mixed content.


More information about the Python-list mailing list