Created 05-09-2017 02:57 PM
xpath.pngMy NiFi Flow is:
GenerateFlowFile --> UpdateAttribute --> InvokeHTTP --> EvaluateXPath --> LogAttribute
My xml data returned by InvokeHTTP Is :
<?xml version="1.0" ?> <queryResponse type="HCC" rootUrl="https://xyz/data" requestUrl="https://xyz/data/HCC" responseType="listEntityInstances" count="253561" first="0" last="999"> <entity url="https://xyz/data/HCC/790189306" type="HCC" dtoType="hccDTO"> <hccDTO id="790189306" displayName="790189306"> <count>0</count> </hccDTO> </entity> </queryResponse>
I want to get "last" attribute's value from EvaluateXPath. Expecting value "999" to be returned but I am getting entire xml in output.
I am attaching the processor details. Kindly let me know where I am going wrong.
Created on 05-09-2017 03:27 PM - edited 08-17-2019 06:34 PM
Try the following for the XPath:
string(/queryResponse/@last)
Also ensure the Destination property is "flowfile-content" and Return is "string", this will ensure the value of the attribute is written as the contents of the outgoing flow file.
Created on 04-24-2018 09:56 AM - edited 08-17-2019 06:33 PM
When I try this, I'm getting an empty string back. Can someone explain why? I'm using NiFi 1.5.0.
My XML looks like this:
<?xml version="1.0" encoding="UTF-8"?> <Log> <Transaction Type="1" TrainingModeFlag="true"> <StoreID>240041</StoreID> ... </Transaction> </Log>
My Workflow splits the XML via SplitXML in depth 1, so after this processor I have this sub-xml:
<Transaction Type="1" TrainingModeFlag="true"> <StoreID>240041</StoreID> ... </Transaction>
I want to extract the value of the Type attribute of the Transaction tag, but it doesn't work for me. Here my EvaluateXPath processor:
My new content attribute has an empty string set, instead of showing the value 1:
Created 04-24-2018 10:02 AM
Reading the Value with the XPath //@Type works fine.