How to parse xml file with python when one tag has two types? -
i want parse xml file using python package xml.etree.celementtree
.in xml file, tag <edge>
has 2 types of atrrs. say
<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>
the parse result of tag edge
finds one
<edge id=":4_0" function="internal">
when delete
`<edge id=":4_0" function="internal">`
it can parse successfully:
`<edge id="-13" from="12" to="1" priority="-1">`
so how can fix it?
i want parse <edge id="-13" from="12" to="1" priority="-1">
when both type of tag edge
exist.thx.
Comments
Post a Comment