[lxml-dev] Serialization with namespaces
Stefan Behnel
stefan_ml at behnel.de
Wed Sep 12 12:19:17 CEST 2007
Anders Bruun Olsen wrote:
> Now the problem occurs when I try to serialize. When I serialize the
> root, everything looks fine:
>
> >>> etree.tostring(root, pretty_print=True)
> '<topicMap xmlns="http://www.topicmaps.org/xtm/1.0/"
> xmlns:xlink="http://www.w3.org/1999/xlink" id="personnavnereg1">
> ...
>
> The XML Namespace is applied as it should. However on the topic-element
> that I found using XPath no XML Namespace is output:
>
> >>> etree.tostring(elem, pretty_print=True)
> '<topic id="abeleHenriksdatter">\n\t\t<instanceOf>\n\t\t\t<topicRef
> ...
>
> Even though the nsmap attribute is set correctly:
>
> >>> elem.nsmap
> {None: 'http://www.topicmaps.org/xtm/1.0/', 'xlink':
> 'http://www.w3.org/1999/xlink'}
Hmm, I actually thought these problems were gone with 1.3, but I can reproduce
this with the current trunk.
I'll look into it.
Stefan
More information about the lxml-dev
mailing list