I am parsing xml output by another program.
Here's an example of the xml fragment:
<result test="Passed" stamp="2011-01-25T12:40:46.166-08:00">
<assertion>MultipleTestTool1</assertion>
<comment>MultipleTestTool1 Passed</comment>
</result>
I want to get the data out of the <comment> element.
Here is my code snippet:
import xml.dom.minidom
mydata.cnodes = mydata.rnode.getElementsByTagName("comment")
value = self.getResultCommentText( mydata.cnodes
def getResultCommentText(self, nodelist):
rc = []
for node in nodelist:
if node.nodeName == "comment":
if node.nodeType == node.TEXT_NODE:
rc.append(node.data)
return ''.join(rc)
value is always empty, and it appears that the nodeType is always an ELEMENT_NODE, so .data doesn't exist I am new to Python, and this is causing me to scratch my head. Can anyone tell me what I'm doing wrong?