from xml.dom import minidom xmldoc = minidom.parse('binary.xml') reflist = xmldoc.getElementsByTagName('ref') reflist print reflist[0].toxml()