Python解析Xml
from lxml import etree def get_info_from_xml(xml_text): try: parser = etree.XMLParser(recover=True) tree = etree.fromstring(bytes(xml_text, encoding='gbk'), parser=parser) result_info = tree.find("movie_title") #查找指定的节点 if result_info is None: return "" else: return result_info.text except Exception as e: print(e) return ""
标签:Xml,info,return,Python,text,parser,result,解析 From: https://www.cnblogs.com/aaronhoo/p/16788332.html