classification
Title: xml.etree.ElementTree Elment.find bug, fails to find tag
Type: enhancement Stage: resolved
Components: XML Versions: Python 3.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: spacether
Priority: normal Keywords:

Created on 2018-12-19 01:49 by spacether, last changed 2018-12-19 02:21 by spacether. This issue is now closed.

Messages (2)
msg332106 - (view) Author: Justin (spacether) Date: 2018-12-19 01:49
When the following text it loaded in to an ElementTree Element, the find method is unable to find one of the elements without a namespace assigned to it.
```
import xml.etree.ElementTree as ElementTree

xml_text = """
<ns0:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/"><ns0:Body><ns0:Fault><faultcode>a:ActionNotSupported</faultcode><faultstring xml:lang="en-US">The message with Action \'\' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).</faultstring></ns0:Fault></ns0:Body></ns0:Envelope>
"""

xml = ElementTree.fromstring(xml_text)
ele = xml.find('faultstring')
ele == None #True
```
msg332107 - (view) Author: Justin (spacether) Date: 2018-12-19 02:21
Issue was user error. I though that find did a full search of the tree when it only searches children.
Solution is:

ele = xml.find('.//faultstring')
History
Date User Action Args
2018-12-19 02:21:36spacethersetstatus: open -> closed
resolution: not a bug
messages: + msg332107

stage: resolved
2018-12-19 01:49:24spacethercreate