I have an XML file generated by a specific SW, and there is an issue with one element, which content I cannot influence as I would like to. So I decided to try to update it with XMLUpdater, but I am just walking in the circles.
The (very simplified) file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<gdb:Utilities xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:atr="atr"... etc.>
<gdb:Data>
<gdb:BiogasStations>
<bgs:Records>
<bgs:Record>
...
<atr:IDZone>58KVK-96</atr:IDZone>
<atr:IDSpecific>0</atr:IDSPecific>
...
</bgs:Record>
<bgs:Record>
...
<atr:IDZone>58KVK-07</atr:IDZone>
<atr:IDSpecific>0</atr:IDSPecific>
...
</bgs:Record>
<bgs:Record>
...
<atr:IDZone>18LIK-15</atr:IDZone>
<atr:IDSpecific>0</atr:IDSPecific>
...
</bgs:Record>
...
</bgs:Records>
</gdb:BiogasStations>
</gdb:Data>
</gdb:Utilities>
I would like to replace the content of the IDSpecific element with newSpecificID values from an XLS spreadsheet, which is very simple:
rowID | newSpecificID |
---|---|
0 | 11890 |
1 | 11891 |
2 | 11892 |
The desired result would look like the following code. The order of newSpecificIDs replaced does not matter, it would be first-come, first-served.
<?xml version="1.0" encoding="UTF-8"?>
<gdb:Utilities xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:atr="atr"... etc.>
<gdb:Data>
<gdb:BiogasStations>
<bgs:Records>
<bgs:Record>
...
<atr:IDZone>58KVK-96</atr:IDZone>
<atr:IDSpecific>11890</atr:IDSPecific>
...
</bgs:Record>
<bgs:Record>
...
<atr:IDZone>58KVK-07</atr:IDZone>
<atr:IDSpecific>11891</atr:IDSPecific>
...
</bgs:Record>
<bgs:Record>
...
<atr:IDZone>18LIK-15</atr:IDZone>
<atr:IDSpecific>11892</atr:IDSPecific>
...
</bgs:Record>
...
</bgs:Records>
</gdb:BiogasStations>
</gdb:Data>
</gdb:Utilities>
But I was not able to achieve this. When I used the whole file as an XML input, every record was updated with the last value of 11892. When I used Records as XML input, I got everything three times, the value being again 11892. I tried to look around and thought that building a list from newSpecificIDs and using a loop would help, but I have not been able to implement them, my XQuery knowledge is superficial. This XMLUpdater setup did not work, my newbie loop merely put all IDS inside the element together. I will be thankful for any help.
Update Type | XML Path | Value Type | Value |
---|---|---|---|
Replace contents | //atr:IDSpecific | XML/XQuery |
|