Python 将XML文件中包含的部分数据转换为CSV文件

Python 将XML文件中包含的部分数据转换为CSV文件,python,xml,csv,Python,Xml,Csv,我想在python中将XML文件转换为CSV文件。下面我附上一张hom XML文件的照片,看起来像,我希望每个id(例如PZH01_MST_0690_00)都能获取最小流量,在这种情况下,它将是:60。有人能帮我吗?我想经验丰富的人可以很容易做到这一点。本质上,我想将这个XML文件转换为CSV,并有两列(1列具有id,2列具有最低流量)。任何帮助都将不胜感激,谢谢 <?xml version="1.0" encoding="UTF-8"?> -<SOAP:Envelope x

我想在python中将XML文件转换为CSV文件。下面我附上一张hom XML文件的照片,看起来像,我希望每个id(例如PZH01_MST_0690_00)都能获取最小流量,在这种情况下,它将是:60。有人能帮我吗?我想经验丰富的人可以很容易做到这一点。本质上,我想将这个XML文件转换为CSV,并有两列(1列具有id,2列具有最低流量)。任何帮助都将不胜感激,谢谢

<?xml version="1.0" encoding="UTF-8"?>

-<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">


-<SOAP:Body>


-<d2LogicalModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" modelBaseVersion="2" xmlns="http://datex2.eu/schema/2/2_0">


-<exchange>


-<supplierIdentification>

<country>nl</country>

<nationalIdentifier>NLNDW</nationalIdentifier>

</supplierIdentification>

</exchange>


-<payloadPublication lang="nl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MeasuredDataPublication">

<publicationTime>2019-10-31T11:12:42.005Z</publicationTime>


-<publicationCreator>

<country>nl</country>

<nationalIdentifier>NLNDW</nationalIdentifier>

</publicationCreator>

<measurementSiteTableReference targetClass="MeasurementSiteTable" version="1139" id="NDW01_MT"/>


-<headerInformation>

<confidentiality>noRestriction</confidentiality>

<informationStatus>real</informationStatus>

</headerInformation>


-<siteMeasurements xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<measurementSiteReference targetClass="MeasurementSiteRecord" version="6" id="PZH01_MST_0690_00"/>

<measurementTimeDefault>2019-10-31T11:11:00Z</measurementTimeDefault>


-<measuredValue index="1">


-<measuredValue>


-<basicData xsi:type="TrafficFlow">


-<vehicleFlow>

<vehicleFlowRate>720</vehicleFlowRate>

</vehicleFlow>

</basicData>

</measuredValue>

</measuredValue>


-<measuredValue index="2">


-<measuredValue>


-<basicData xsi:type="TrafficFlow">


-<vehicleFlow>

<vehicleFlowRate>60</vehicleFlowRate>

</vehicleFlow>

</basicData>

</measuredValue>

</measuredValue>


-<measuredValue index="3">


-<measuredValue>


-<basicData xsi:type="TrafficFlow">


-<vehicleFlow>

<vehicleFlowRate>60</vehicleFlowRate>

</vehicleFlow>

</basicData>

</measuredValue>

</measuredValue>


-<measuredValue index="4">


-<measuredValue>


-<basicData xsi:type="TrafficFlow

-
-
-
-
-
nl
NLNDW
-
2019-10-31T11:12:42.005Z
-
nl
NLNDW
-
无限制
真实的
-
2019-10-31T11:11:00Z
-
-
-
-
720
-
-
-
-
60
-
-
-
-
60
-
-

-您可以在这里共享XML内容吗?1)请向我们展示您的尝试。有什么问题?2) 请将XML作为文本而不是图像发布。我尝试添加XML内容,但结构发生了很多变化。这是我最大的努力