DOM method to go to the tag with particular attribute value ..with example
DOM method to go to the tag with particular attribute value ..with example
Collapse
X
-
Here's a simple example:elemList is a list of the elements with the tag "pitch". To get the text from the child element:Code:from xml.dom.minidom import parseString xml_str = """<?xml version="1.0" ?> <ROOT> <pitch>The data is in between opening and closing tags.</pitch> <pitch>More data</pitch> </ROOT>""" xmlDoc = parseString(xml_str) elemList = xmlDoc.getElementsByTagName('pitch')Code:for elem in elemList: for child in elem.childNodes: print child.nodeValue
Comment