Python xml.dom.createComment() Examples
The following are 30
code examples of xml.dom.createComment().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
xml.dom
, or try the search function
.
Example #1
Source File: test_minidom.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def testAppendChild(self): dom = parse(tstfile) dom.documentElement.appendChild(dom.createComment(u"Hello")) self.confirm(dom.documentElement.childNodes[-1].nodeName == "#comment") self.confirm(dom.documentElement.childNodes[-1].data == "Hello") dom.unlink()
Example #2
Source File: test_minidom.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def testSerializeCommentNodeWithDoubleHyphen(self): doc = create_doc_without_doctype() doc.appendChild(doc.createComment("foo--bar")) self.assertRaises(ValueError, doc.toxml)
Example #3
Source File: test_minidom.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def testWholeText(self): doc = parseString("<doc>a</doc>") elem = doc.documentElement text = elem.childNodes[0] self.assertEqual(text.nodeType, Node.TEXT_NODE) self.checkWholeText(text, "a") elem.appendChild(doc.createTextNode("b")) self.checkWholeText(text, "ab") elem.insertBefore(doc.createCDATASection("c"), text) self.checkWholeText(text, "cab") # make sure we don't cross other nodes splitter = doc.createComment("comment") elem.appendChild(splitter) text2 = doc.createTextNode("d") elem.appendChild(text2) self.checkWholeText(text, "cab") self.checkWholeText(text2, "d") x = doc.createElement("x") elem.replaceChild(x, splitter) splitter = x self.checkWholeText(text, "cab") self.checkWholeText(text2, "d") x = doc.createProcessingInstruction("y", "z") elem.replaceChild(x, splitter) splitter = x self.checkWholeText(text, "cab") self.checkWholeText(text2, "d") elem.removeChild(splitter) self.checkWholeText(text, "cabd") self.checkWholeText(text2, "cabd")
Example #4
Source File: test_minidom.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def testRenameOther(self): # We have to create a comment node explicitly since not all DOM # builders used with minidom add comments to the DOM. doc = xml.dom.minidom.getDOMImplementation().createDocument( xml.dom.EMPTY_NAMESPACE, "e", None) node = doc.createComment("comment") self.assertRaises(xml.dom.NotSupportedErr, doc.renameNode, node, xml.dom.EMPTY_NAMESPACE, "foo") doc.unlink()
Example #5
Source File: test_minidom.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def testNonZero(self): dom = parse(tstfile) self.confirm(dom)# should not be zero dom.appendChild(dom.createComment("foo")) self.confirm(not dom.childNodes[-1].childNodes) dom.unlink()
Example #6
Source File: test_minidom.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def testAppendChild(self): dom = parse(tstfile) dom.documentElement.appendChild(dom.createComment(u"Hello")) self.confirm(dom.documentElement.childNodes[-1].nodeName == "#comment") self.confirm(dom.documentElement.childNodes[-1].data == "Hello") dom.unlink()
Example #7
Source File: test_minidom.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def testSerializeCommentNodeWithDoubleHyphen(self): doc = create_doc_without_doctype() doc.appendChild(doc.createComment("foo--bar")) self.assertRaises(ValueError, doc.toxml)
Example #8
Source File: test_minidom.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def testWholeText(self): doc = parseString("<doc>a</doc>") elem = doc.documentElement text = elem.childNodes[0] self.assertEqual(text.nodeType, Node.TEXT_NODE) self.checkWholeText(text, "a") elem.appendChild(doc.createTextNode("b")) self.checkWholeText(text, "ab") elem.insertBefore(doc.createCDATASection("c"), text) self.checkWholeText(text, "cab") # make sure we don't cross other nodes splitter = doc.createComment("comment") elem.appendChild(splitter) text2 = doc.createTextNode("d") elem.appendChild(text2) self.checkWholeText(text, "cab") self.checkWholeText(text2, "d") x = doc.createElement("x") elem.replaceChild(x, splitter) splitter = x self.checkWholeText(text, "cab") self.checkWholeText(text2, "d") x = doc.createProcessingInstruction("y", "z") elem.replaceChild(x, splitter) splitter = x self.checkWholeText(text, "cab") self.checkWholeText(text2, "d") elem.removeChild(splitter) self.checkWholeText(text, "cabd") self.checkWholeText(text2, "cabd")
Example #9
Source File: test_minidom.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def testRenameOther(self): # We have to create a comment node explicitly since not all DOM # builders used with minidom add comments to the DOM. doc = xml.dom.minidom.getDOMImplementation().createDocument( xml.dom.EMPTY_NAMESPACE, "e", None) node = doc.createComment("comment") self.assertRaises(xml.dom.NotSupportedErr, doc.renameNode, node, xml.dom.EMPTY_NAMESPACE, "foo") doc.unlink()
Example #10
Source File: test_minidom.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def testNonZero(self): dom = parse(tstfile) self.confirm(dom)# should not be zero dom.appendChild(dom.createComment("foo")) self.confirm(not dom.childNodes[-1].childNodes) dom.unlink()
Example #11
Source File: test_minidom.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def testAppendChild(self): dom = parse(tstfile) dom.documentElement.appendChild(dom.createComment(u"Hello")) self.confirm(dom.documentElement.childNodes[-1].nodeName == "#comment") self.confirm(dom.documentElement.childNodes[-1].data == "Hello") dom.unlink()
Example #12
Source File: test_minidom.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def testSerializeCommentNodeWithDoubleHyphen(self): doc = create_doc_without_doctype() doc.appendChild(doc.createComment("foo--bar")) self.assertRaises(ValueError, doc.toxml)
Example #13
Source File: test_minidom.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def testWholeText(self): doc = parseString("<doc>a</doc>") elem = doc.documentElement text = elem.childNodes[0] self.assertEqual(text.nodeType, Node.TEXT_NODE) self.checkWholeText(text, "a") elem.appendChild(doc.createTextNode("b")) self.checkWholeText(text, "ab") elem.insertBefore(doc.createCDATASection("c"), text) self.checkWholeText(text, "cab") # make sure we don't cross other nodes splitter = doc.createComment("comment") elem.appendChild(splitter) text2 = doc.createTextNode("d") elem.appendChild(text2) self.checkWholeText(text, "cab") self.checkWholeText(text2, "d") x = doc.createElement("x") elem.replaceChild(x, splitter) splitter = x self.checkWholeText(text, "cab") self.checkWholeText(text2, "d") x = doc.createProcessingInstruction("y", "z") elem.replaceChild(x, splitter) splitter = x self.checkWholeText(text, "cab") self.checkWholeText(text2, "d") elem.removeChild(splitter) self.checkWholeText(text, "cabd") self.checkWholeText(text2, "cabd")
Example #14
Source File: test_minidom.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def testRenameOther(self): # We have to create a comment node explicitly since not all DOM # builders used with minidom add comments to the DOM. doc = xml.dom.minidom.getDOMImplementation().createDocument( xml.dom.EMPTY_NAMESPACE, "e", None) node = doc.createComment("comment") self.assertRaises(xml.dom.NotSupportedErr, doc.renameNode, node, xml.dom.EMPTY_NAMESPACE, "foo") doc.unlink()
Example #15
Source File: test_minidom.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def testNonZero(self): dom = parse(tstfile) self.confirm(dom)# should not be zero dom.appendChild(dom.createComment("foo")) self.confirm(not dom.childNodes[-1].childNodes) dom.unlink()
Example #16
Source File: test_minidom.py From ironpython2 with Apache License 2.0 | 5 votes |
def testAppendChild(self): dom = parse(tstfile) dom.documentElement.appendChild(dom.createComment(u"Hello")) self.confirm(dom.documentElement.childNodes[-1].nodeName == "#comment") self.confirm(dom.documentElement.childNodes[-1].data == "Hello") dom.unlink()
Example #17
Source File: test_minidom.py From oss-ftp with MIT License | 5 votes |
def testSerializeCommentNodeWithDoubleHyphen(self): doc = create_doc_without_doctype() doc.appendChild(doc.createComment("foo--bar")) self.assertRaises(ValueError, doc.toxml)
Example #18
Source File: test_minidom.py From oss-ftp with MIT License | 5 votes |
def testWholeText(self): doc = parseString("<doc>a</doc>") elem = doc.documentElement text = elem.childNodes[0] self.assertEqual(text.nodeType, Node.TEXT_NODE) self.checkWholeText(text, "a") elem.appendChild(doc.createTextNode("b")) self.checkWholeText(text, "ab") elem.insertBefore(doc.createCDATASection("c"), text) self.checkWholeText(text, "cab") # make sure we don't cross other nodes splitter = doc.createComment("comment") elem.appendChild(splitter) text2 = doc.createTextNode("d") elem.appendChild(text2) self.checkWholeText(text, "cab") self.checkWholeText(text2, "d") x = doc.createElement("x") elem.replaceChild(x, splitter) splitter = x self.checkWholeText(text, "cab") self.checkWholeText(text2, "d") x = doc.createProcessingInstruction("y", "z") elem.replaceChild(x, splitter) splitter = x self.checkWholeText(text, "cab") self.checkWholeText(text2, "d") elem.removeChild(splitter) self.checkWholeText(text, "cabd") self.checkWholeText(text2, "cabd")
Example #19
Source File: test_minidom.py From oss-ftp with MIT License | 5 votes |
def testRenameOther(self): # We have to create a comment node explicitly since not all DOM # builders used with minidom add comments to the DOM. doc = xml.dom.minidom.getDOMImplementation().createDocument( xml.dom.EMPTY_NAMESPACE, "e", None) node = doc.createComment("comment") self.assertRaises(xml.dom.NotSupportedErr, doc.renameNode, node, xml.dom.EMPTY_NAMESPACE, "foo") doc.unlink()
Example #20
Source File: test_minidom.py From oss-ftp with MIT License | 5 votes |
def testNonZero(self): dom = parse(tstfile) self.confirm(dom)# should not be zero dom.appendChild(dom.createComment("foo")) self.confirm(not dom.childNodes[-1].childNodes) dom.unlink()
Example #21
Source File: test_minidom.py From oss-ftp with MIT License | 5 votes |
def testAppendChild(self): dom = parse(tstfile) dom.documentElement.appendChild(dom.createComment(u"Hello")) self.confirm(dom.documentElement.childNodes[-1].nodeName == "#comment") self.confirm(dom.documentElement.childNodes[-1].data == "Hello") dom.unlink()
Example #22
Source File: test_minidom.py From BinderFilter with MIT License | 5 votes |
def testSerializeCommentNodeWithDoubleHyphen(self): doc = create_doc_without_doctype() doc.appendChild(doc.createComment("foo--bar")) self.assertRaises(ValueError, doc.toxml)
Example #23
Source File: test_minidom.py From BinderFilter with MIT License | 5 votes |
def testWholeText(self): doc = parseString("<doc>a</doc>") elem = doc.documentElement text = elem.childNodes[0] self.assertEqual(text.nodeType, Node.TEXT_NODE) self.checkWholeText(text, "a") elem.appendChild(doc.createTextNode("b")) self.checkWholeText(text, "ab") elem.insertBefore(doc.createCDATASection("c"), text) self.checkWholeText(text, "cab") # make sure we don't cross other nodes splitter = doc.createComment("comment") elem.appendChild(splitter) text2 = doc.createTextNode("d") elem.appendChild(text2) self.checkWholeText(text, "cab") self.checkWholeText(text2, "d") x = doc.createElement("x") elem.replaceChild(x, splitter) splitter = x self.checkWholeText(text, "cab") self.checkWholeText(text2, "d") x = doc.createProcessingInstruction("y", "z") elem.replaceChild(x, splitter) splitter = x self.checkWholeText(text, "cab") self.checkWholeText(text2, "d") elem.removeChild(splitter) self.checkWholeText(text, "cabd") self.checkWholeText(text2, "cabd")
Example #24
Source File: test_minidom.py From BinderFilter with MIT License | 5 votes |
def testRenameOther(self): # We have to create a comment node explicitly since not all DOM # builders used with minidom add comments to the DOM. doc = xml.dom.minidom.getDOMImplementation().createDocument( xml.dom.EMPTY_NAMESPACE, "e", None) node = doc.createComment("comment") self.assertRaises(xml.dom.NotSupportedErr, doc.renameNode, node, xml.dom.EMPTY_NAMESPACE, "foo") doc.unlink()
Example #25
Source File: test_minidom.py From BinderFilter with MIT License | 5 votes |
def testNonZero(self): dom = parse(tstfile) self.confirm(dom)# should not be zero dom.appendChild(dom.createComment("foo")) self.confirm(not dom.childNodes[-1].childNodes) dom.unlink()
Example #26
Source File: test_minidom.py From BinderFilter with MIT License | 5 votes |
def testAppendChild(self): dom = parse(tstfile) dom.documentElement.appendChild(dom.createComment(u"Hello")) self.confirm(dom.documentElement.childNodes[-1].nodeName == "#comment") self.confirm(dom.documentElement.childNodes[-1].data == "Hello") dom.unlink()
Example #27
Source File: test_minidom.py From ironpython2 with Apache License 2.0 | 5 votes |
def testSerializeCommentNodeWithDoubleHyphen(self): doc = create_doc_without_doctype() doc.appendChild(doc.createComment("foo--bar")) self.assertRaises(ValueError, doc.toxml)
Example #28
Source File: test_minidom.py From ironpython2 with Apache License 2.0 | 5 votes |
def testWholeText(self): doc = parseString("<doc>a</doc>") elem = doc.documentElement text = elem.childNodes[0] self.assertEqual(text.nodeType, Node.TEXT_NODE) self.checkWholeText(text, "a") elem.appendChild(doc.createTextNode("b")) self.checkWholeText(text, "ab") elem.insertBefore(doc.createCDATASection("c"), text) self.checkWholeText(text, "cab") # make sure we don't cross other nodes splitter = doc.createComment("comment") elem.appendChild(splitter) text2 = doc.createTextNode("d") elem.appendChild(text2) self.checkWholeText(text, "cab") self.checkWholeText(text2, "d") x = doc.createElement("x") elem.replaceChild(x, splitter) splitter = x self.checkWholeText(text, "cab") self.checkWholeText(text2, "d") x = doc.createProcessingInstruction("y", "z") elem.replaceChild(x, splitter) splitter = x self.checkWholeText(text, "cab") self.checkWholeText(text2, "d") elem.removeChild(splitter) self.checkWholeText(text, "cabd") self.checkWholeText(text2, "cabd")
Example #29
Source File: test_minidom.py From ironpython2 with Apache License 2.0 | 5 votes |
def testRenameOther(self): # We have to create a comment node explicitly since not all DOM # builders used with minidom add comments to the DOM. doc = xml.dom.minidom.getDOMImplementation().createDocument( xml.dom.EMPTY_NAMESPACE, "e", None) node = doc.createComment("comment") self.assertRaises(xml.dom.NotSupportedErr, doc.renameNode, node, xml.dom.EMPTY_NAMESPACE, "foo") doc.unlink()
Example #30
Source File: test_minidom.py From ironpython2 with Apache License 2.0 | 5 votes |
def testNonZero(self): dom = parse(tstfile) self.confirm(dom)# should not be zero dom.appendChild(dom.createComment("foo")) self.confirm(not dom.childNodes[-1].childNodes) dom.unlink()