Changing a value of an xml field after extracting from request
I am trying to extract the "ns1: month" field from the following request using XML Databank and then increase the value by 3 and populate it in response.
<?xml version="1.0" encoding="UTF-8"?>
CallingAppCode
VLM0
RZZCA82
26
06
2019
Q
.
Please suggest a solution for this.
Comments
-
Hi,
The example you posted doesn't look like xml, maybe it got garbled when the post was submitted. The data bank tool will help you generate the xpath to select the particular xml element you want, then you can manually edit the selection xpath and can add math functions to do the addition.0 -
The request is not getting posted
0 -
Could you attach the sample xml as a file?
0 -
Using the xml data bank I input the xml and from the tree view I clicked the month element. Then I edited the xpath to add " + 1" to the end. Here is the final xpath will return the value 7 for the sample provided.
/:Envelope/:Body[1]/:GetNextNextPaymentDateRequest[1]/:getNextNextPaymentDateReq[1]/:nextPayDate[1]/:month[1]/text() + 1
0 -
It worked. Thanks William
0 -
Glad it worked
0 -
It is not handling when month equals to 10 because it will throw 13 as the month value.
0 -
I am guessing you mean that when the month is 12 then the data bank returns 13. Here is an xpath that uses max and mod to keep the values within the values 1-12
max ((1, (/:Envelope/:Body[1]/:GetNextNextPaymentDateRequest[1]/:getNextNextPaymentDateReq[1]/:nextPayDate[1]/:month[1]/text() + 1) mod 13))
0 -
Getting this error: Problem evaluating XPath expression. Error message = "net.sf.saxon.trans.XPathException: A sequence of more than one item is not allowed as the first operand of 'mod' (1, 9) "
0 -
What version of the product are you using?
0 -
9.10
0 -
What service pack version? I tested the xpath with 9.10.6 and it worked.
0 -
Hi,
I missed that you wanted to increment by 3 months. This should work for that case, its some funny math but it works for values 9, 10, 11 and 12 where as the previous solutions did not.Does this work for you?
(/:Envelope/:Body[1]/:GetNextNextPaymentDateRequest[1]/:getNextNextPaymentDateReq[1]/:nextPayDate[1]/:month[1]/text() -1 + 3) mod 12 + 1
1