コード例 #1
0
ファイル: test_minidom.py プロジェクト: zushilong003/jython3
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()
コード例 #2
0
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()
コード例 #3
0
# test for xml.dom.minidom