[lxml-dev] iterparse and namespaces

Piotr Furman piotr.furman at webservice.pl
Tue Mar 17 16:39:58 CET 2009


Stefan Behnel <stefan_ml <at> behnel.de> writes:

> 
> Piotr Furman wrote:
> >  <jholg <at> gmx.de> writes:
> >> Is there a usecase for "give me every element x from whatever
> >> namespace"?
> >
> > Thanks for answer, my use case is that I have a xml file with only one
> > namespace
> > defined in root. I guess that if there were more namespaces in one file it
> > wouldn't make sense, but as long as it's only one I just don't care about
> > that and would have all specified elements.
> 
> uh? Then I really don't get it. If there is only one namespace that
> contains all elements, then why can't you just look for the tags in
> exactly that namespace? That will give you all tags with that name.
> 
> Stefan

Sure I can, but my real data is little bigger than this sample. Each element
found with iterparse has many other tags I'd like to retrieve, using "iter"
method. Here again, for each tag I would have to add namespace. If I do this in
several lines code will be ugly. It would be also harder to maintain, if for
some reason somebody would change xmlns one day.

So it would be nice if iterparse could accept wildcard as namespace, but I see
it can be solved another way.

PF



More information about the lxml-dev mailing list