[lxml-dev] iterparse and namespaces
Stefan Behnel
stefan_ml at behnel.de
Tue Mar 17 15:48:54 CET 2009
jholg at gmx.de wrote:
>> > Is that possible to get all tags "a" without passing namespace? I
>> mean,
>> a2
>> > works, but could it be possible to make a1 working too?
>>
>> ..., tag="{*}a"
>>
>> might work.
>
> I thought so too but it doesn't :)
Thanks for checking. :)
> The wildcard works for element names, not for namespaces:
>
>>>> for e in etree.iterparse(StringIO(xml),
>>>> tag="{http://www.example.com}*"): print e
> ...
> (u'end', <Element {http://www.example.com}a at 2d7510>)
> (u'end', <Element {http://www.example.com}a at 2d7570>)
> (u'end', <Element {http://www.example.com}root at 2675a0>)
>>>>
>
> Same holds for .iter().
>
> Is there a usecase for "give me every element x from whatever namespace"?
Yep, I guess that's why it doesn't work. :)
Maybe the OP can give us a clearer idea about the background of this request.
Stefan
More information about the lxml-dev
mailing list