Python xml Function

Python xml.dom module handles XML data structure easily. Suppose we have a XML structure file "tp.txt":

<ResultSet date="2013-02-26 07:43:10">
<Query>TTRE</Query>
<Hits>1</Hits>
<Result id="1">
<analysis_id>2a891a941fe3</analysis_id>
<state>live</state>
<last_modified>2011-08-26T07:00:00Z</last_modified>
<upload_date></upload_date>
<center_name>XTRCD</center_name>
<study>phs000178</study>
<aliquot_id>4a8c8a7df3a5</aliquot_id>
<files>
<file>
<filename>test.txt</filename>
<filesize>59264187</filesize>
</file>
</files>

</Result>
</ResultSet>

Get all sub nodes names under node "Result":
from xml.dom import minidom
rxml = minidom.parse('tp.txt')
arr = rxml.getElementsByTagName('Result')
print(len(arr))
print(arr[0].nodeName)
print(arr[0].childNodes)
x = arr[0].childNodes
for i in x:
print(i.nodeName)
1
Result
analysis_id
state
last_modified
upload_date
center_name
study
aliquot_id
files
data_uri