Created 08-23-2017 05:44 PM
I have response like this and i want to extract ErrorCode value from response flowfile anc check if it is equal to -7 and if it is, I will have to log this. I tried this in EvaluateXpath processor:/Error/ErrorCode/text() but it doesn't work for me after passing EvaluateXpath processor flowfile attribute errorCode which i have added with above mentioned command(/Error/ErrorCode/text()) seems to be emty string set
<Result xmlns="olineservice" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <ResponseStatus>false</ResponseStatus> <Error> <ErrorCode>-7</ErrorCode> <ErrorDescription>data wasn't found</ErrorDescription> </Error> </Result>
Created 08-23-2017 07:45 PM
From my answer to this question on Stack Overflow:
To extract the desired value, use the XPath expression
//ErrorCode
. This will return a String
value -7. By selecting Destination
flowfile-attribute, you can keep the flowfile content constant and put this new value in a flowfile attribute (i.e. named attribute
).
You can chain the matched
relationship to an UpdateAttribute
processor which has the expression ${attribute:toNumber()}
to convert it to a numerical representation, i.e. ${attribute:toNumber():plus(10)}
would return 3.
Created 08-23-2017 07:45 PM
From my answer to this question on Stack Overflow:
To extract the desired value, use the XPath expression
//ErrorCode
. This will return a String
value -7. By selecting Destination
flowfile-attribute, you can keep the flowfile content constant and put this new value in a flowfile attribute (i.e. named attribute
).
You can chain the matched
relationship to an UpdateAttribute
processor which has the expression ${attribute:toNumber()}
to convert it to a numerical representation, i.e. ${attribute:toNumber():plus(10)}
would return 3.