On 21 Mai, 22:58, emperorcezar <emperorce...@gmail.com> wrote: > I'm new to using the xml libs. I'm trying to create xml pragmatically, > but I'm finding an issue. I have two elements I'm creating using > createElementNS two elements (soap:Envelope and context). Each having > a different namespace. When I print the created xml, the namespace > attribute gets moved from the context element to the envelope element. > Is there a reason for this, and how can I get it to not do that?
Having the default namespace declared on an ancestor of the context element is completely valid in this case, since the soap:Envelope element is associated with a different namespace. You could see what happens if you serialise the document using a different library function or document/node method, however. > Code: > from xml.dom import implementation > from xml.dom.ext import PrettyPrint > > namespace = 'http://www.w3.org/2003/05/soap-envelope' > > # create XML DOM document > doc = implementation.createDocument(None, '', None) [...] Note that according to the specifications, the element name should be None (null) for this kind of createDocument invocation. See here for details: http://www.w3.org/TR/DOM-Level-3-Core/core.html#Level-2-Core-DOM-createDocument Paul -- http://mail.python.org/mailman/listinfo/python-list