How to check for end of tag in Python using minidom?
<p>I'm trying to create an expression from an XML. Reading from top node I want to put the node one by one into a stack, once I hit a closing tag I want to pop all elements in the stack. How do I check the end of a tag ?.</p>

<p>TIA, </p>

<p>John</p>

<p>Answer: </p>

<p>OK, I think I've the solution, using a recursive function like this:</p>

<pre><code>def findTextNodes(nodeList):
    for subnode in nodeList:
        if subnode.nodeType == subnode.ELEMENT_NODE:
            print("element node: ",subnode.tagName)
            # call function again to get children
            findTextNodes(subnode.childNodes)
            print('subnode return: ', subnode.tagName)
        elif subnode.nodeType == subnode.TEXT_NODE:
            print("text node: ",subnode.data)
</code></pre>

<p>When the 'subnode return' it hits the closing tag!.</p>

<p>Thanks everybody!.</p>
