Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Using EvaluateXpath prossessor in nifi

Solved Go to solution

Using EvaluateXpath prossessor in nifi

New Contributor

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

  1. what should i change to get value of ErrorCode in errorcode atribute?
<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>
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Using EvaluateXpath prossessor in nifi

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.

1 REPLY 1

Re: Using EvaluateXpath prossessor in nifi

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.

Don't have an account?
Coming from Hortonworks? Activate your account here