Python xml.dom.getElementsByTagName() Examples
The following are 14
code examples of xml.dom.getElementsByTagName().
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 CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def testNormalizedAfterLoad(self): """ Introduced this test on jython because 1. Cpython guarantees, by the use of xml.dom.expatbuilder, that all text nodes are normalized after loading. 2. Jython has no expat, and thus uses xml.dom.pulldom.parse (which uses any java SAX2 compliant parser), and which makes no guarantees about text node normalization. Thus we have to check if text nodes are normalized after a parse. See this bug for further information minidom chunks the character input on multi-line values http://bugs.jython.org/issue1614 """ num_lines = 2 # Up to 16K lines should be enough to guarantee failure without normalization while num_lines <= 2**14: doc_content = "\n".join( ("Line %d" % i for i in xrange(num_lines)) ) doc_text = "<document>%s</document>" % doc_content dom = parseString(doc_text) node_content = dom.getElementsByTagName("document")[0].childNodes[0].nodeValue self.confirm(node_content == doc_content, "testNormalizedAfterLoad") num_lines *= 2
Example #2
Source File: test_minidom.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def testNormalizedAfterLoad(self): """ Introduced this test on jython because 1. Cpython guarantees, by the use of xml.dom.expatbuilder, that all text nodes are normalized after loading. 2. Jython has no expat, and thus uses xml.dom.pulldom.parse (which uses any java SAX2 compliant parser), and which makes no guarantees about text node normalization. Thus we have to check if text nodes are normalized after a parse. See this bug for further information minidom chunks the character input on multi-line values http://bugs.jython.org/issue1614 """ num_lines = 2 # Up to 16K lines should be enough to guarantee failure without normalization while num_lines <= 2**14: doc_content = "\n".join( ("Line %d" % i for i in xrange(num_lines)) ) doc_text = "<document>%s</document>" % doc_content dom = parseString(doc_text) node_content = dom.getElementsByTagName("document")[0].childNodes[0].nodeValue self.confirm(node_content == doc_content, "testNormalizedAfterLoad") num_lines *= 2
Example #3
Source File: test_minidom.py From ironpython2 with Apache License 2.0 | 5 votes |
def testGetElementsByTagName(self): dom = parse(tstfile) self.confirm(dom.getElementsByTagName("LI") == \ dom.documentElement.getElementsByTagName("LI")) dom.unlink()
Example #4
Source File: test_minidom.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_toprettyxml_preserves_content_of_text_node(self): # see issue #4147 for str in ('<B>A</B>', '<A><B>C</B></A>'): dom = parseString(str) dom2 = parseString(dom.toprettyxml()) self.assertEqual( dom.getElementsByTagName('B')[0].childNodes[0].toxml(), dom2.getElementsByTagName('B')[0].childNodes[0].toxml())
Example #5
Source File: test_minidom.py From BinderFilter with MIT License | 5 votes |
def testGetElementsByTagName(self): dom = parse(tstfile) self.confirm(dom.getElementsByTagName("LI") == \ dom.documentElement.getElementsByTagName("LI")) dom.unlink()
Example #6
Source File: test_minidom.py From BinderFilter with MIT License | 5 votes |
def test_toprettyxml_preserves_content_of_text_node(self): # see issue #4147 for str in ('<B>A</B>', '<A><B>C</B></A>'): dom = parseString(str) dom2 = parseString(dom.toprettyxml()) self.assertEqual( dom.getElementsByTagName('B')[0].childNodes[0].toxml(), dom2.getElementsByTagName('B')[0].childNodes[0].toxml())
Example #7
Source File: test_minidom.py From oss-ftp with MIT License | 5 votes |
def testGetElementsByTagName(self): dom = parse(tstfile) self.confirm(dom.getElementsByTagName("LI") == \ dom.documentElement.getElementsByTagName("LI")) dom.unlink()
Example #8
Source File: test_minidom.py From oss-ftp with MIT License | 5 votes |
def test_toprettyxml_preserves_content_of_text_node(self): # see issue #4147 for str in ('<B>A</B>', '<A><B>C</B></A>'): dom = parseString(str) dom2 = parseString(dom.toprettyxml()) self.assertEqual( dom.getElementsByTagName('B')[0].childNodes[0].toxml(), dom2.getElementsByTagName('B')[0].childNodes[0].toxml())
Example #9
Source File: test_minidom.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def testGetElementsByTagName(self): dom = parse(tstfile) self.confirm(dom.getElementsByTagName("LI") == \ dom.documentElement.getElementsByTagName("LI")) dom.unlink()
Example #10
Source File: test_minidom.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_toprettyxml_preserves_content_of_text_node(self): # see issue #4147 for str in ('<B>A</B>', '<A><B>C</B></A>'): dom = parseString(str) dom2 = parseString(dom.toprettyxml()) self.assertEqual( dom.getElementsByTagName('B')[0].childNodes[0].toxml(), dom2.getElementsByTagName('B')[0].childNodes[0].toxml())
Example #11
Source File: test_minidom.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def testGetElementsByTagName(self): dom = parse(tstfile) self.confirm(dom.getElementsByTagName("LI") == \ dom.documentElement.getElementsByTagName("LI")) dom.unlink()
Example #12
Source File: test_minidom.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_toprettyxml_preserves_content_of_text_node(self): # see issue #4147 for str in ('<B>A</B>', '<A><B>C</B></A>'): dom = parseString(str) dom2 = parseString(dom.toprettyxml()) self.assertEqual( dom.getElementsByTagName('B')[0].childNodes[0].toxml(), dom2.getElementsByTagName('B')[0].childNodes[0].toxml())
Example #13
Source File: test_minidom.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def testGetElementsByTagName(self): dom = parse(tstfile) self.confirm(dom.getElementsByTagName("LI") == \ dom.documentElement.getElementsByTagName("LI")) dom.unlink()
Example #14
Source File: test_minidom.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_toprettyxml_preserves_content_of_text_node(self): # see issue #4147 for str in ('<B>A</B>', '<A><B>C</B></A>'): dom = parseString(str) dom2 = parseString(dom.toprettyxml()) self.assertEqual( dom.getElementsByTagName('B')[0].childNodes[0].toxml(), dom2.getElementsByTagName('B')[0].childNodes[0].toxml())