xml.dom.minidom weirdness: bug?
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Wed Apr 30 05:46:15 EDT 2008
En Tue, 29 Apr 2008 23:51:14 -0300, JYA <nospam at nospam.blah> escribió:
> What I'm doing, is read an xml file, create another dom object and copy
> the element from one to the other.
>
> At no time do I ever modify the original dom object, yet it gets
> modified.
>
> for y in x.getElementsByTagName('display-name'):
> elem.appendChild(y)
> tv_xml.appendChild(elem)
> You'll note that at no time do I modify the content of docxml, yet it
> gets modified.
>
> The weirdness disappear if I change the line
> channellist = docxml.getElementsByTagName('channel')
> to
> channellist = copy.deepcopy(docxml.getElementsByTagName('channel'))
>
> However, my understanding is that it shouldn't be necessary.
I think that any element can have only a single parent. If you get an
element from one document and insert it onto another document, it gets
removed from the first.
--
Gabriel Genellina
More information about the Python-list
mailing list