具有复杂结构(时间戳)的Python XML解析

具有复杂结构(时间戳)的Python XML解析,python,xml,parsing,parameters,Python,Xml,Parsing,Parameters,如何正确解析以下xml代码? 我尝试了许多其他示例代码,但它们在我的情况下似乎不起作用。 特别是对于逗号分隔的数据结构 这可能很简单: <parameter> <parameterName>Device.DMversion</parameterName> <parameterValue type="xs:string">02.00</parameterValue> </parameter> Dev

如何正确解析以下xml代码? 我尝试了许多其他示例代码,但它们在我的情况下似乎不起作用。 特别是对于逗号分隔的数据结构

这可能很简单:

   <parameter>
   <parameterName>Device.DMversion</parameterName>
   <parameterValue type="xs:string">02.00</parameterValue>
   </parameter>

Device.DMversion
2
但这个有点复杂:

<parameter>
<parameterName>Device.LANDevice.1.WLANConfiguration.1.AssociationHistory.1.MACAddress</parameterName>
<parameterValue type="xs:string">aa:bb</parameterValue>
</parameter>
<parameter>
<parameterName>Device.LANDevice.1.WLANConfiguration.1.AssociationHistory.1.AssociationTime</parameterName>
<parameterValue type="xs:dateTime">2013-05-31T07:30:39-07:00</parameterValue>
</parameter>

Device.LANDevice.1.WLANConfiguration.1.AssociationHistory.1.MACAddress
aa:bb
Device.LANDevice.1.WLANConfiguration.1.AssociationHistory.1.AssociationTime
2013-05-31T07:30:39-07:00
更复杂一点: 时间戳值在“ClientStats”之后立即更改:4-->5-->6 我喜欢平均所有时间戳的参数值

<parameter>
<parameterName>Device.LANDevice.1.WLANConfiguration.1.AssociatedDevice.1.ClientStats.4.CLIENT_STATS_Index</parameterName>
<parameterValue type="xs:unsignedInt">3</parameterValue>
</parameter>
<parameter>
<parameterName>Device.LANDevice.1.WLANConfiguration.1.AssociatedDevice.1.ClientStats.5.CLIENT_STATS_Index</parameterName>
<parameterValue type="xs:unsignedInt">3</parameterValue>
</parameter><parameter>
<parameterName>Device.LANDevice.1.WLANConfiguration.1.AssociatedDevice.1.ClientStats.6.CLIENT_STATS_Index</parameterName>
<parameterValue type="xs:unsignedInt">3</parameterValue>
</parameter>

Device.LANDevice.1.WLANConfiguration.1.associated Device.1.ClientStats.4.CLIENT\u STATS\u Index
3.
Device.LANDevice.1.WLANConfiguration.1.associated Device.1.ClientStats.5.CLIENT\u STATS\u Index
3.
Device.LANDevice.1.WLANConfiguration.1.associated Device.1.ClientStats.6.CLIENT\u STATS\u Index
3.
不要编写自己的代码来完成这项工作,否则你会搞砸所有你没有想到或没有意识到存在的特殊情况