[lxml-dev] prefix mappings
Hi,
I would like to generate the following serialization:
<a xmls="foo">
<b xmls="bar"/>
</a>
Currently, the closest I can come is:
<a xmls="foo" xmlns:x="bar">
FnH wrote:
I would like to generate the following serialization:
<a xmls="foo"> <b xmls="bar"/> </a> [...] In order to solve this I think it would be a good idea to allow (or take into account) prefix mappings on non root nodes as well. The output I'd like could then be achieved by the following code snippet:
a = Element("{foo}a", nsmap={None:"foo"}) a.append(Element("{bar}b", nsmap={None:"bar"}))
from lxml.etree import Element, tostring
a = Element("{foo}a", nsmap={None:"foo"}) a.append(Element("{bar}b", nsmap={None:"bar"}))
print tostring(a, pretty_print=True) <a xmlns="foo"> <b xmlns="bar"/> </a>
This is on lxml 2.0 alpha, lxml 1.3 should work alike. Stefan
participants (2)
-
FnH
-
Stefan Behnel