Getting elements and text with lxml

J. Pablo Fernández pupeno at pupeno.com
Fri May 16 17:53:03 EDT 2008


Hello,

I have an XML file that starts with:

<vortaro>
<art mrk="$Id: a.xml,v 1.10 2007/09/11 16:30:20 revo Exp $">
<kap>
  <ofc>*</ofc>-<rad>a</rad>
</kap>

out of it, I'd like to extract something like (I'm just showing one
structure, any structure as long as all data is there is fine):

[("ofc", "*"), "-", ("rad", "a")]

How can I do it? I managed to get the content of boths tags and the
text up to the first tag ("\n   "), but not the - (and in other XML
files, there's more text outside the elements).

Thanks.



More information about the Python-list mailing list