Here is my code:
def extract_infos(i): blabla... blabla calculate v... dom = xml.dom.minidom.parseString(v) return dom doc = xml.dom.minidom.Document() for i in range(1,100): dom = extract_infos(i) for child in dom.childNodes: doc.appendChild(child.cloneNode(True))
The last two lines work once:
Traceback (most recent call last): File "./c.py", line 197, in <module> doc.appendChild(child.cloneNode(True)) File "/usr/lib/python2.6/xml/dom/minidom.py", line 1552, in appendChild "two document elements disallowed") xml.dom.HierarchyRequestErr: two document elements disallowed
So my question is: how to put two existing documents in a new document (by placing the root elements of each in a new, more complete root element).
source share