Damjan <[EMAIL PROTECTED]> wrote:
> Given the folowing XML snippet, I build an ElementTree instance with
> et=ElementTree.fromstring(..). Now et.text returns just '\n text\n some
> other text'.
> Is there any way I could get everything between the <div> and </div> tag?
>
> <div>
> text
> some other text<br/>
> and then some more
> </div>
def gettext(elem):
text = elem.text or ""
for subelem in elem:
text = text + gettext(subelem)
if subelem.tail:
text = text + subelem.tail
return text
>>> gettext(et)
'\n text\n some other text\n and then some more\n'
</F>
--
http://mail.python.org/mailman/listinfo/python-list