document as child in DOM ??
and-google at doxdesk.com
Mon Nov 8 10:54:47 CET 2004
Uche Ogbuji <uche at ogbuji.net> wrote:
[on reparenting the root element]
> 4) root_dom.documentElement = new_docelem
Unfortunately documentElement is a readonly property, so this won't
fly. (minidom doesn't generate the expected NoModificationAllowedErr,
but it doesn't perform the replacement either.)
You'd have to say:
Bizarrely, this isn't *guaranteed* to work; in DOM Level 2 Core it's
optional, and an implementation might respond with a NotSupportedErr.
However, minidom, 4DOM and pxdom seem quite happy with it.
[Well, now. It didn't work in Python 2.0's minidom. But then what
Juliano Freitas <jubafre at atlas.ucpel.tche.br> wrote:
> xmltext = """<?xml version='1.0'?>
> i want tu put this "xmltext" as a child to another document called
Another way of doing it would be DOM Level 3 LS's parseWithContext
# doc is a Document containing an <swdb/> element
# xmltext is as above
parser= doc.implementation.createLSParser(1, None)
parser.parseWithContext(input, el, parser.ACTION_APPEND_AS_CHILDREN)
LS isn't yet widely supported; pxdom will grok it but 4DOM won't.
mailto:and at doxdesk.com
More information about the Python-list