I need to edit some XML files, and would like to create a script to do this. My experience with XML is almost non-existent, which is why I’m asking your help.
The XML below contains 2 transport orders: one that has a positive value element, and one that has a negative value. What I would like to do is, for every transport order that contains negative value:
- replace the pickup_task‘s addressid with the delivery task‘s addressid, and vice versa
- replace the pickup task’s taskwindow (from_instant and till_instant) with the values of the delivery task.
Is it possible to make a VB script or batch or something that could replace these for a file with more than 200 transport_orders?
Thanks
<?xml version="1.0" encoding="iso-8859-2"?>
<misu version="2010">
<transport_orders>
<transport_order>
<id>NOCCO/12-006798_1</id>
<order_number>NOCCO/12-006798_1</order_number>
<order_date>2012-03-30</order_date>
<contactId>C04396</contactId>
<productId>0103-01101025</productId>
<sum>3135.51</sum>
<currency_code></currency_code>
<reference>NOCCO/12-006798</reference>
<amounts>
<amount>
<unit_code>kg</unit_code>
<value>324.00</value>
</amount>
</amounts>
<pickup_task>
<addressid>BUCU</addressid>
<task_window>
<from_instant>2012-04-20T18:26:43</from_instant>
<till_instant>2012-04-20T18:26:43</till_instant>
</task_window>
</pickup_task>
<delivery_task>
<addressid>C04396_1</addressid>
<task_window>
<from_instant>2012-04-23T00:00:00</from_instant>
<till_instant>2012-04-24T00:00:00</till_instant>
</task_window>
</delivery_task>
</transport_order>
<transport_order>
<id>NOCCO/12-007016_2</id>
<order_number>NOCCO/12-007016_2</order_number>
<order_date>2012-04-02</order_date>
<contactId>C01137</contactId>
<productId>0604-08L15000</productId>
<sum>495.00</sum>
<currency_code></currency_code>
<reference>NOCCO/12-007016</reference>
<amounts>
<amount>
<unit_code>m2</unit_code>
<value>-5.00</value>
</amount>
</amounts>
<pickup_task>
<addressid>SFGH</addressid>
<task_window>
<from_instant>2012-04-20T18:26:43</from_instant>
<till_instant>2012-04-20T18:26:43</till_instant>
</task_window>
</pickup_task>
<delivery_task>
<addressid>C01137_1</addressid>
<task_window>
<from_instant>2012-04-23T00:00:00</from_instant>
<till_instant>2012-04-24T00:00:00</till_instant>
</task_window>
</delivery_task>
</transport_order>
</transport_orders>
</misu>
Here ya go … this should accomplish part 1. I’ll leave part 2 up to you (I’m not used to VB). As you can see I named the XML file “data.xml”.