我有一个XML文件,其中有一些测试限制,我想提取并写入xls文件。在
<TestLimitSet>
<AppName>Test Application</AppName>
<Name>High-Speed test app</Name>
<SummaryName>limit set 1.0</SummaryName>
<SharedReference>DUT Specification Version 1.0</SharedReference>
<TestLimits>
<!--########## Host Electrical Specification ##########-->
<!--Host Strobe Frequency-->
<TestLimit>
<ID>1101, 1102</ID>
<SummaryName>Host Strobe Frequency</SummaryName>
<SummaryDescription>The frequency must within the specification.</SummaryDescription>
<Reference>Section 3.</Reference>
<PrecisionLevel>0.01E+6</PrecisionLevel>
<PassLimits>
<Type>RANGE_INCLUSIVE</Type>
<Min>239.88E+6</Min>
<Max>240.12E+6</Max>
</PassLimits>
</TestLimit>
<!--Host Data Slew Rate-->
<TestLimit>
<ID>1201</ID>
<SummaryName>Host Data Slew Rate</SummaryName>
<SummaryDescription>Slew rate must within the specification.</SummaryDescription>
<Reference>Section 4.</Reference>
<PrecisionLevel>0.001</PrecisionLevel>
<PassLimits>
<Type>RANGE_INCLUSIVE</Type>
<Min>0.7</Min>
<Max>2.0</Max>
</PassLimits>
</TestLimit>
<!--Host Strobe Slew Rate-->
<TestLimit>
<ID>1202</ID>
<SummaryName>Host Strobe Slew Rate</SummaryName>
<SummaryDescription>Slew rate must within the specification.</SummaryDescription>
<Reference>Section 5.</Reference>
<PrecisionLevel>0.001</PrecisionLevel>
<PassLimits>
<Type>RANGE_INCLUSIVE</Type>
<Min>0.7</Min>
</PassLimits>
</TestLimit>
</TestLimits>
在 我使用以下python代码提取数据:
^{pr2}$这是输出:
TestName: Host Strobe Frequency
Type RANGE_INCLUSIVE
Min 239.88E+6
Max 240.12E+6
TestName: Host Data Slew Rate
Type RANGE_INCLUSIVE
Min 239.88E+6
Max 240.12E+6
TestName: Host Strobe Slew Rate
Type RANGE_INCLUSIVE
Min 239.88E+6
Max 240.12E+6
问题是“Min”和“Max”总是来自XML中的第一个节点,而不是测试名称下的相应部分。有人能帮忙解决这个问题吗?在
这是因为您在循环中使用了
document.find
,它每次都返回相同的节点。你应该走这条路:相关问题 更多 >
编程相关推荐