Parsing XML issue

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

Can you please change it to a minimal self-contained runnable code? I.e. put the input data to a variable and read them later from the variable. Maybe like this?

input_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"/>
'''

In your code we do not know for example what is the tree variable… Check that the code runs without errors except errors which you would like to help with.

I do not understand this. pder and text are attributes in your XML, not elements. It is also unclear how they should be joined. Maybe show how the output should look like for the given input data.

Should this be…?

i.e. pder and texts

What editor are you using? Is it an IDE like PyCharm or VS Code?

Have you tried setting a breakpoint in your innermost loop and looking at values as it cycles through?