lxml, get xml between elements



given this sample xml:



<xml>
<pb facs="id1" />
<test></test>
<test></test>
<pb facs="id2" />
<test></test>
<test></test>
</xml>


i need to parse it and get the content between pb


what is the correct xpath axe to use?



from lxml import etree
xml = etree.parse("sample.xml")

for pb in xml.xpath('//pb'):
print pb.xpath('@facs')[0]
print {{ HOW TO GET THE CONTENT HERE? }}

No comments:

Post a Comment