我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用xml.dom.createElementNS()。
def testRemoveAttrNS(self): dom = Document() child = dom.appendChild( dom.createElementNS("http://www.python.org", "python:abc")) child.setAttributeNS("http://www.w3.org", "xmlns:python", "http://www.python.org") child.setAttributeNS("http://www.python.org", "python:abcattr", "foo") self.confirm(len(child.attributes) == 2) child.removeAttributeNS("http://www.python.org", "abcattr") self.confirm(len(child.attributes) == 1) dom.unlink()
def testElementReprAndStrUnicodeNS(self): dom = Document() el = dom.appendChild( dom.createElementNS("http://www.slashdot.org", "slash:abc")) string1 = repr(el) string2 = str(el) self.confirm(string1 == string2) self.confirm("slash:abc" in string1) dom.unlink()
def testElementReprAndStrUnicodeNS(self): dom = Document() el = dom.appendChild( dom.createElementNS(u"http://www.slashdot.org", u"slash:abc")) string1 = repr(el) string2 = str(el) self.confirm(string1 == string2) self.confirm("slash:abc" in string1) dom.unlink()