I'm trying to update a xml-file with data from a pandas DataFrame: The xml-file looks like this:
<root>
<NetworkData>
<Element loadid="23" type="Load" node1="N23">
<Name>load1</Name>
<ShortName/>
<InputState>1027</InputState>
<x>11</x>
<y>15</y>
</Element>
<Element loadid="24" type="Load" node1="N24">
<Name>load2</Name>
<ShortName/>
<InputState>1027</InputState>
<x>0.75</x>
<y>600</y>
</Element>
...
The DataFrame looks like:
| ID | x | y |
|---|---|---|
| 23 | 17 | 29 |
| 24 | 123 | 543 |
| ... | ... | ... |
The ID is identical to the loadid in the xml-file. My aim is to update the values x and y in the xml-file with the values from the Dataframe. Is there a easy way do to this because the Dataframe is quite long? By the way all loadids can be found as IDs in the Dataframe.
Output xml-file:
<root>
<NetworkData>
<Element loadid="23" type="Load" node1="N23">
<Name>load1</Name>
<ShortName/>
<InputState>1027</InputState>
<x>17</x>
<y>29</y>
</Element>
<Element loadid="24" type="Load" node1="N24">
<Name>load2</Name>
<ShortName/>
<InputState>1027</InputState>
<x>123</x>
<y>543</y>
</Element>
...
Thank you!