下面是 XML 文件:<Schedule xmlns="http://xmlns.xyz.com/fal/downtimeschedule/V1.0"> <Downtime end="20181020000" id="10001197610_20181027000_201810000" mode="cold" start="20181020000"/> <PODS> <POD DC="US - Washing" deferUpgrade="true" name="ABCD" patching="Production" EndTime="20181028040000"> <CR id="12345"/> <CR id="12346"/> <CR id="123"/> </POD> <POD DC="US - Washing" deferUpgrade="true" name="ABCD-TEST" patching="Production" EndTime="20181028040000"> <CR id="12345"/> <CR id="12346"/> <CR id="123"/> </POD> </PODS>我想在带有列的 csv 文件中提供输出1> POD(name)2> POD(DC)3> POD(deferUpgrade)有人可以在这里帮忙。是否可以使用库 xml.etree.ElementTree,因为我在生产环境中有这个。下面是代码。#!/usr/bin/pythonimport osimport pandas as pdimport requestsimport xml.etree.ElementTree as ETtree = ET.parse('schedule.xml')root = tree.getroot()print rootprint root.findall('PODS')for pods in root.iter('Schedule'): for pod in pods.iter('POD'): print pod.get('name')输出:<Element '{http://xmlns.oracle.com/falcm/flo/downtimeschedule/V1.0}Schedule' at 0x2ae6ed0>[]
添加回答
举报
0/150
提交
取消