libxml2dom

tests/namespaces2.py

205:16a9ae746a73
2006-07-28 paulb [project @ 2006-07-28 19:50:05 by paulb] Updated copyright information.
     1 #!/usr/bin/env python     2      3 import libxml2dom, xml.dom, xml.dom.minidom     4      5 document = libxml2dom.createDocument(None, "doc", None)     6 top = document.xpath("*")[0]     7 elem1 = document.createElementNS("DAV:", "myns:href")     8 elem1.setAttributeNS(xml.dom.XMLNS_NAMESPACE, "xmlns:myns", "DAV:")     9 elem1.setAttributeNS(xml.dom.XMLNS_NAMESPACE, "xmlns:otherns", "urn")    10 document.replaceChild(elem1, top)    11 print document.toString()    12     13 document2 = xml.dom.minidom.Document()    14 elem1 = document2.createElementNS("DAV:", "myns:href")    15 elem1.setAttributeNS(xml.dom.XMLNS_NAMESPACE, "xmlns:myns", "DAV:")    16 elem1.setAttributeNS(xml.dom.XMLNS_NAMESPACE, "xmlns:otherns", "urn")    17 document2.appendChild(elem1)    18 print document2.toxml()    19     20 # vim: tabstop=4 expandtab shiftwidth=4