Pheipha
9 years agoFrequent Visitor
Groovy scripting
I want to perform some calculation of several values in a response and want to validate the outcome
of the calculation with other fields from the response using groovy script
For example
I want to sum up all the values of hours*norm that are found in the response
SUM =
(Record1/Data/Data1/hours*norm) + (Record1/Data/Data2/hours*norm) +
(Record2/Data/Data1/hours*norm) + (Record2/Data/Data2/hours*norm)
The SUM will be compared with another value in the response, with Value of Buget/TotalAmount
Can anyone help me out with this?
XML:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Resultaat xmlns="http://tempuri.org/"> <Records> <Record1> <Record1A> <StartDate xmlns="">2015-01-01</StartDate> <EndDate xmlns="">2016-03-21</EndDate> <ID xmlns="">257404491</ID> <Budget xmlns=""> <TotalAmount>3521397</TotalAmount> <StartDate>2015-01-01</StartDate> <EndDate>2015-12-31</EndDate> <MaxAmount>52820</MaxAmount> <Functiebudget> <Bedrag>3521397</Bedrag> </Functiebudget> </Budget> <Budget xmlns=""> <TotalAmount>788392</TotalAmount> <StartDate>2016-01-01</StartDate> <EndDate>2016-03-21</EndDate> <MaxAmount>0</MaxAmount> <Functiebudget> <Bedrag>788392</Bedrag> </Functiebudget> </Budget> </Record1A> <Data> <Data1> <ID>3749908</ID> <Hours>173685</Hours> <NORM>0.01</NORM> <DTStartDate>2015-01-01T00:00:00</DTStartDate> <DTEndDate>2016-03-21T00:00:00</DTEndDate> </Data1> <Data2> <ID>3749908</ID> <Hours>173685</Hours> <NORM>0.01</NORM> <DTStartDate>2015-01-01T00:00:00</DTStartDate> <DTEndDate>2016-03-21T00:00:00</DTEndDate> </Data2> </Data> </Record1> <Record2> <Record2A> <StartDate xmlns="">2015-01-01</StartDate> <EndDate xmlns="">2016-03-21</EndDate> <ID xmlns="">257404491</ID> <Budget xmlns=""> <TotalAmount>3521397</TotalAmount> <StartDate>2015-01-01</StartDate> <EndDate>2015-12-31</EndDate> <MaxAmount>52820</MaxAmount> </Budget> <Budget xmlns=""> <TotalAmount>788392</TotalAmount> <StartDate>2016-01-01</StartDate> <EndDate>2016-03-21</EndDate> <MaxAmount>0</MaxAmount> </Budget> </Record2A> <Data> <Data1> <ID>3749908</ID> <Hours>173685</Hours> <NORM>0.01</NORM> <DTStartDate>2015-01-01T00:00:00</DTStartDate> <DTEndDate>2016-03-21T00:00:00</DTEndDate> </Data1> <Data2> <ID>3749908</ID> <Hours>173685</Hours> <NORM>0.01</NORM> <DTStartDate>2015-01-01T00:00:00</DTStartDate> <DTEndDate>2016-03-21T00:00:00</DTEndDate> </Data2> </Data> </Record2> </Beschikkingen> </Resultaat> </s:Body> </s:Envelope>