xml文档: <GetMatchingProductResult ASIN="B071LF9R6G" status=Success">...</GetMatchingProductResult> <GetMatchingProductResult ASIN=B0714BP3H4B0756FL8R7">...</GetMatchingProductResult> <ResponseMetadata> # 使用minidom解析器打开XML文档 DOMTree = xml.dom.minidom.parse(./test.xml") collection = DOMTree.documentElement collection是针对整个文件的文档,GetMatchingProductResults 获取的是三个名字相同的标签,不同标签的数据对象 GetMatchingProductResults = collection.getElementsByTagName('GetMatchingProductResult') GetMatching 是针对每个标签对象GetMatching作为xml对象进行对应取值 for GetMatching in GetMatchingProductResults: asin = GetMatching.getElementsByTagName(ASIN)[0].childNodes[0].data print(asin)