Módulo ElementTree Python: Como ignorar o namespace dos arquivos XML para localizar o elemento correspondente ao usar o método “find”, “findall”

Eu quero usar o método de "findall" para localizar alguns elementos do arquivo xml de origem no módulo ElementTree.

No entanto, o arquivo xml de origem (test.xml) possui espaço para nome. Eu truncar parte do arquivo xml como exemplo:

<?xml version="1.0" encoding="iso-8859-1"?>
<XML_HEADER xmlns="http://www.test.com">
    <TYPE>Updates</TYPE>
    <DATE>9/26/2012 10:30:34 AM</DATE>
    <COPYRIGHT_NOTICE>All Rights Reserved.</COPYRIGHT_NOTICE>
    <LICENSE>newlicense.htm</LICENSE>
    <DEAL_LEVEL>
        <PAID_OFF>N</PAID_OFF>
        </DEAL_LEVEL>
</XML_HEADER>

O código python de amostra está abaixo:

from xml.etree import ElementTree as ET
tree = ET.parse(r"test.xml")
el1 = tree.findall("DEAL_LEVEL/PAID_OFF") # Return None
el2 = tree.findall("{http://www.test.com}DEAL_LEVEL/{http://www.test.com}PAID_OFF") # Return <Element '{http://www.test.com}DEAL_LEVEL/PAID_OFF' at 0xb78b90>

Embora possa funcionar, porque existe um namespace "{http://www.test.com}", é muito inconveniente adicionar um namespace na frente de cada tag.

Como posso ignorar o namespace ao usar o método "find", "findall" e assim por diante?

questionAnswers(7)

yourAnswerToTheQuestion