[XML-SIG] copy node to new dom
Hannu Krosing
hannu@tm.ee
Thu, 25 Oct 2001 23:28:34 +0500
Mike Hostetler wrote:
>
> On Thu, October 25, 2001 at 09:47:44AM -0700, Michael Mell wrote:
> > Hi,
> > I want to use xml.dom.minidom to parse a file, extract the document
> > element and then duplicate that element in a second dom. Ideally, these
> > four lines would do the job:
> > srcDom = xml.dom.minidom.parse(f1)
> > destDom = xml.dom.minidom.parse(f2)
> > srcElement = srcDom.getElementsByTagName('myElement')[0]
> >
> > destDom.documentElement.appendChild(srcElement)
>
> I used the Sax reader from PyXML and just did:
> destDom.importNode(srcElement,deep=1) # copies all child nodes as well
> destDom.documentElement.appendChild(srcElement)
>
> However, minidom doesn't have an 'importNode" method. I've found minidom
> is not up to the task when doing advanced things (and taking part of a
> DOM tree and putting it into another DOM tree *is* advanced). I hate to
> sound elitest, but change to PyXML -- it will make things easier.
It _would_ probably make things easier if it were documented ;)
I've just spent a few hours searching for documentation and the only
more or
less complete doc's I found were for minidom in standard python docs.
The docs that come with PyXML had just placeholders for most things.
------------------
Hannu