Martin v. Loewis, 15.05.2010 23:37:
BTW, I'm still not sure I understand your problem. Could you provide
some more details?
Wouldn't it be easier if you told the OP how to access the prefix
mappings in lxml etree, or, if this was actually not possible, admitted
that it is actually not possible?
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. Prefixes can get defined and
redefined arbitrarily often, so there is no such thing as a
prefix-namespace mapping "of the document". Example:
<x:tag xmlns:x="urn:uri1">
<x:tag xmlns:x="urn:uri2">
<x:tag xmlns:x="urn:uri3 />
</x:tag>
</x:tag>
Trying to infer a prefix-namespace mapping from that to push it into an
XPath evaluation is futile.
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.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list