我想使用python包xml.etree.cElementTree
解析xml文件。在我的xml文件中,标记<edge>
有两种类型的atrrs。说
<edge id=":4_0" function="internal">
<lane id=":4_0_0" index="0" speed="16.70" length="4.82" shape="0.20,756.75 -1.13,756.08 -1.64,755.31 -1.33,754.44 -0.20,753.48"/>
</edge>
<edge id="-13" from="12" to="1" priority="-1">
<lane id="-13_0" index="0" speed="16.70" length="1580.67" shape="2665.90,1464.08 1332.42,615.33"/>
<lane id="-13_1" index="1" speed="16.70" length="1580.67" shape="2667.67,1461.29 1334.19,612.54"/>
<lane id="-13_2" index="2" speed="16.70" length="1580.67" shape="2669.44,1458.51 1335.97,609.76"/>
<lane id="-13_3" index="3" speed="16.70" length="1580.67" shape="2671.21,1455.72 1337.74,606.97"/>
</edge>
标记edge
的解析结果只能找到一个
<edge id=":4_0" function="internal">
当我删除所有
时`<edge id=":4_0" function="internal">`
它可以成功解析:
`<edge id="-13" from="12" to="1" priority="-1">`
那我该怎么办呢?
当两种类型的标记<edge id="-13" from="12" to="1" priority="-1">
都存在时,我想解析edge
.Thx。