Reading XML namespaces

Martin v. Loewis martin at v.loewis.de
Sun May 16 03:07:53 EDT 2010


> Well, there's an "nsmap" property on each Element that provides the
> mapping of prefixes to namespace URIs that form the scope of the
> Element. However, while this is what the OP asked for, it is not what
> the OP wants, simply because it doesn't solve the problem.

Well, it solves the problem at hand: he gets some prefix mapping.

He probably could have used a hard-coded prefix mapping for the 20 or so
namespaces in his application instead (with a different set of flaws in
that approach).

> That's why I asked for more details in order to understand what the
> actual problem is that the OP is trying to solve, because the approach
> that the OP is apparently trying to follow is clearly misguided.

I completely agree. However, I recommend that we let him find out on his
 own. I suspect he has some idiomatic usage of XML, perhaps with all
namespace prefixes defined in the root element. He'll find out that his
approach is flawed in the general case when he encounters such a case.
It's probably pointless trying to convince him in the abstract.

Regards,
Martin



More information about the Python-list mailing list