def testLegalChildren(): dom = Document() elem = dom.createElement('element') text = dom.createTextNode('text') try: dom.appendChild(text) except HierarchyRequestErr: pass else: print("dom.appendChild didn't raise HierarchyRequestErr") dom.appendChild(elem) try: dom.insertBefore(text, elem) except HierarchyRequestErr: pass else: print("dom.appendChild didn't raise HierarchyRequestErr") try: dom.replaceChild(text, elem) except HierarchyRequestErr: pass else: print("dom.appendChild didn't raise HierarchyRequestErr") nodemap = elem.attributes try: nodemap.setNamedItem(text) except HierarchyRequestErr: pass else: print("NamedNodeMap.setNamedItem didn't raise HierarchyRequestErr") try: nodemap.setNamedItemNS(text) except HierarchyRequestErr: pass else: print("NamedNodeMap.setNamedItemNS didn't raise HierarchyRequestErr") elem.appendChild(text) dom.unlink()
def testLegalChildren(): dom = Document() elem = dom.createElement('element') text = dom.createTextNode('text') try: dom.appendChild(text) except HierarchyRequestErr: pass else: print "dom.appendChild didn't raise HierarchyRequestErr" dom.appendChild(elem) try: dom.insertBefore(text, elem) except HierarchyRequestErr: pass else: print "dom.appendChild didn't raise HierarchyRequestErr" try: dom.replaceChild(text, elem) except HierarchyRequestErr: pass else: print "dom.appendChild didn't raise HierarchyRequestErr" nodemap = elem.attributes try: nodemap.setNamedItem(text) except HierarchyRequestErr: pass else: print "NamedNodeMap.setNamedItem didn't raise HierarchyRequestErr" try: nodemap.setNamedItemNS(text) except HierarchyRequestErr: pass else: print "NamedNodeMap.setNamedItemNS didn't raise HierarchyRequestErr" elem.appendChild(text) dom.unlink()
# test for xml.dom.minidom