<?xml Version ="1.0"encoding ="Utf-8"?><root> <body name="LYC"> <age>110</age> </body> <body name ="L"Age ="Ten"> </body></root>###################### #Coding=utf8 fromXml.etreeImportElementTree#xmlText = open ("Xml.txt"). Read ()#root = elementtree.fromstring (xmlText)Root= Elementtree.parse ("Xml.txt") Bodys= Root.getiterator ("Body") #Getiterator method getsPrint "Getiterator"PrintBodysPrintdir (bodys[0])Print "attrib:", Bodys[0].attribPrint "tag:", Bodys[0].tagPrint "text", Bodys[0].text#GetChildren method getsPrint "GetChildren"Children=Bodys[0].getchildren ()PrintChildrenPrint "attrib:", Children[0].attribPrint "tag:", Children[0].tagPrint "Text:", Children[0].text#FindPrint "Find"Children= Root.find ("Body")PrintChildrenPrint "attrib:", Children.attribPrint "tag:", Children.tagPrint "Text:", Children.text#FindAllPrint "FindAll"Children= Root.findall ("Body")PrintChildrenPrint "attrib:", Children[0].attribPrint "tag:", Children[0].tagPrint "Text:", Children[0].text
AA = xml.dom.minidom.parseString (response_res). Documentelement.getelementsbytagname (' string ') [0].childnodes[0]. Data
Doc = etree. XML (AA)
Doc.xpath ("//boarddata") [0].getchildren () [0].text
Python xml.etree.ElementTree parse XML file get node