Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

how to get xml node value in nifi processor?

avatar
Contributor

I have nifi processor EvaluateXpath and i want to get tags value from xml response , for it i use expression like this //count/text() but my count attribute is still empty , what should i change? my xml reponse is something like this, AND I WANT TO GET THIS 72 AND WRITE IT IN MY COUNT ATTRIBUTE .

<SendMessagexmlns=""><EnvelopeVersion>2.0</EnvelopeVersion><Header><MessageDetails><Class></Class><Qualifier>response</Qualifier><Function></Function><CorrelationID></CorrelationID><ResponseEndPoint/></MessageDetails><SenderDetails><IDAuthentication/><EmailAddress/></SenderDetails></Header><MessageDetails/><Body><Messagexmlns=""><getEventDataResponsexmlns=""xmlns:ns2=""xmlns:ns3=""xmlns:ns4=""><count>72</count></Message>
3 REPLIES 3

avatar
Super Guru
@sally sally

Is this the right XML you have copied here? It is not a valid XML.

avatar
Contributor

yes but it isn't my whole response i mean i have copied only the part in which is count tag

avatar
Master Guru

Hi @sally sally, if you are extracting only one value to attribute then its easy to use

ExtractText processor:-

by adding new property to it by adding regex like below.

<count>(.*)<\/count>

ExtractText Processor configs:-

40542-extract-text.png

This regex only captures the value in <count></count> message and adds an attribute count to the flowfile.