I’m trying to parse and xml document to get several values for the Astronomy club.
Here is a snippet of the XML.
<Page title=" TESTOO" backColor="Black" rows="50" cols="120">
<FA text="TESTOOO" col="1" row="2" backColor="Blue" foreColor="White"/>
<FA text="Another TESTOO " col="1" row="4" >
<FA text="blah" col="1" row="5" >
<FA text="blah blah="10" row="5" >
<OA pder="XXXX111" col="29" row="5" >
<FA text="val" col="50" row="5" foreColor="LightYellow"/>
The problem I am having is parsing both FA and OA elements and getting their child values.
from lxml import etree
for nodez in tree.iter('Page'):
z01 = nodez.attrib.get('title')
for node2 in tree.iter('FA'):
texts = node.attrib.get('text')
print ('texts')
for node in tree.iter('OA'):
parm = node.attrib.get('pder')
print (parm, texts)
My desired output would be…
have elements joined i,e pder and texts…
Currently the code ends up in a big infinite loop