This is an XML parser code snippet which returns with None value. This is a large XML file that has a lot of subfields like this:
<root>
    <field name ="1">
        <field name ="2" showname ="ZZZ">
            <field name ="3" showname="YYY">
                <field name ="4" showname="XXX"/>
            </field>
        </field>
    </field>
The findall() finds all the elements with a tag which are direct children of the current element. I tried this, but it returned with None. It prints nothing also.
def findXXX(field):
    if field.get('name') == 'XXX' :
        return field.get('showname')
    else:
        for fieldchild in field.findall('field'):
            return findXXX(fieldchild)
If I write like this, it prints the correct value, however it returns with None.
def findXXX(field):
    if field.get('name') == 'XXX' :
        print field.get('showname')
        return field.get('showname')
    else:
        for fieldchild in field.findall('field'):
            findXXX(fieldchild)
 
     
     
    