def testFindSpecific(self): self.assertEqual( "this is the text we want", HelperXml.getNodeText(self.dom, "root", ("node", {"attr": "2"}), "subnode")) self.assertEqual( "other text we may want", HelperXml.getNodeText(self.dom, "root", ("node", {"attr": "3"}), "subnode"))
def testIterNode(self): result = [] expected = ["FOO", "BAR"] for nameElem in HelperXml.iterNodeElement( self.dom, "root", "blap", "subnode", "name" ): result.append(HelperXml.getNodeText(nameElem)) self.assertEqual( result, expected )
def testOldFashionedNode(self): result = [] expected = ["FOO", "BAR"] elem = HelperXml.getNodeElement( self.dom, "root", "blap") for blapChild in elem.childNodes: if blapChild.nodeName == "subnode": for subnodeChild in blapChild.childNodes: if subnodeChild.nodeName == "name": result.append(HelperXml.getNodeText( subnodeChild )) self.assertEqual( result, expected )