0

我有一个以下格式的 xml 文件:

<event time="0.0" type="actend" person="770885_2_Person" link="271711" actType="other"  />
    <event time="0.0" type="departure" person="770885_2_Person" link="271711" legMode="car"  />
    <event time="0.0" type="PersonEntersVehicle" person="770885_2_Person" vehicle="770885_2_Person"  />
    <event time="0.0" type="vehicle enters traffic" person="770885_2_Person" link="271711" vehicle="770885_2_Person" networkMode="car" relativePosition="1.0"  />
    <event time="1.0" type="left link" link="271711"  />
    <event time="1.0" type="entered link" link="271715" vehicle="770885_2_Person"  />
    <event time="15.0" type="left link" link="271715"  />
    <event time="15.0" type="entered link" link="535413" vehicle="770885_2_Person"  />
    <event time="17.0" type="left link" link="535413"  />
    <event time="17.0" type="entered link" link="813064" vehicle="770885_2_Person"  />
    <event time="19.0" type="left link" link="813064"  />
    <event time="19.0" type="entered link" link="813066" vehicle="770885_2_Person"  />
    <event time="22.0" type="left link" link="813066"  />
    <event time="22.0" type="entered link" link="813068" vehicle="770885_2_Person"  />
    <event time="23.0" type="actend" person="368018_2_Person" link="614790" actType="other"  />
    <event time="23.0" type="departure" person="368018_2_Person" link="614790" legMode="car"  />
    <event time="23.0" type="PersonEntersVehicle" person="368018_2_Person" vehicle="368018_2_Person"  />
    <event time="23.0" type="vehicle enters traffic" person="368018_2_Person" link="614790" vehicle="368018_2_Person" networkMode="car" relativePosition="1.0"  />
    <event time="24.0" type="left link" link="614790"  />
....

缺少根节点,因此,当我这样做时,treeEvents = et.parse(file_occup_xml)我得到与缺少根相关的错误(当我手动添加根时,上述解析工作正常)。所以我在这里这里parse()看,但是,在这两种情况下,由于没有根,我实际上无法执行命令。

我在这里想念什么吗?然后如何在该 XML 文件上添加根?

4

0 回答 0