mardi 3 novembre 2015

Enlarge integer tag value in xpath

Could someone please recommend a solution for the following problem.

I have such xml:

<nuts1:SettlementRequest>
           <!--Optional:-->
           <nuts1:MeterReadingId>1842869</nuts1:MeterReadingId>

I need to take MeterReadingId field, add to it 1 and input this value into the next request which should look like:

</nuts:Header>
        <!--Optional:-->
        <nuts1:MeterReadingId>1842870</nuts1:MeterReadingId>

first I used such code:

//*:SettlementRequest/*:MeterReadingId/text()+ 1

But SOAPUI returns the value like

MeterReadingId  [1.84287E6]

That is why I wrote complicated xpath:

concat(substring-before(string(//*:SettlementRequest/*:MeterReadingId/text()+ 1), '.'), substring-before(substring-after(string(//*:SettlementRequest/*:MeterReadingId/text()+ 1), '.'), 'E'))

This piece of code works till you need to increment the Id which ends like ...69 so the final value should be 1842870. This code makes the following:

MeterReadingId  [184287]

It just omits the last 0...So I can not get the correct value. Could someone provide any ideas of how to add 1 to current meterReadingId so that I could receive 1842870.

Thanks

Aucun commentaire:

Enregistrer un commentaire