Message277130
| Author |
py.user |
| Recipients |
py.user |
| Date |
2016年09月21日.12:38:12 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1474461492.99.0.941056742104.issue28238@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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>]
>>> |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2016年09月21日 12:38:13 | py.user | set | recipients:
+ py.user |
| 2016年09月21日 12:38:12 | py.user | set | messageid: <1474461492.99.0.941056742104.issue28238@psf.upfronthosting.co.za> |
| 2016年09月21日 12:38:12 | py.user | link | issue28238 messages |
| 2016年09月21日 12:38:12 | py.user | create |
|