New submission from py.user:

In the example there are two namespaces in one document, but it is impossible 
to search all elements only in one namespace:

>>> import xml.etree.ElementTree as etree
>>>
>>> s = '<feed xmlns="http://def"; xmlns:x="http://x";><a/><x:b/></feed>'
>>>
>>> root = etree.fromstring(s)
>>>
>>> root.findall('*')
[<Element '{http://def}a' at 0xb73961bc>, <Element '{http://x}b' at 0xb7396c34>]
>>>
>>> root.findall('{http://def}*')
[]
>>>


And same try with site package lxml works fine:

>>> import lxml.etree as etree
>>>
>>> s = '<feed xmlns="http://def"; xmlns:x="http://x";><a/><x:b/></feed>'
>>>
>>> root = etree.fromstring(s)
>>>
>>> root.findall('*')
[<Element {http://def}a at 0xb70ab11c>, <Element {http://x}b at 0xb70ab144>]
>>>
>>> root.findall('{http://def}*')
[<Element {http://def}a at 0xb70ab11c>]
>>>

----------
components: Library (Lib), XML
messages: 277130
nosy: py.user
priority: normal
severity: normal
status: open
title: In xml.etree.ElementTree findall() can't search all elements in a 
namespace
type: behavior
versions: Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28238>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to