Add attribute with value

Questions about XML that are not covered by the other forums should go here.
bee123
Posts: 6
Joined: Thu Dec 22, 2016 2:22 pm

Add attribute with value

Post by bee123 » Wed Jan 17, 2018 2:59 pm

Hello,

I have several files where I need to add an attribute with values.
I have a file that looks similar to this:

<text id="124" title="abc" start="1">
<text id="125" title="xyz" start="4">
<text id="126" title="zgh" start="18">
<text id="127" title="jda" start="332">

and i need to add a "end"-attribute with a value of the next element's start attribute's value MINUS 1, so for the the element with the id it would be 3 (because 4-1)
it should look like this:

<text id="124" title="abc" start="1" end="3">
<text id="125" title="xyz" start="4" end="17">
<text id="126" title="zgh" start="18" end="331">
<text id="127" title="jda" start="332" end="">

any ideas or tipps how i could do that fast and easy?
THANK YOU