NIFI - EvaluateXPath to use as attribute

I have an xml that I need to extract the value of chNFe.

<?xml version="1.0" encoding="UTF-8"?>
<nfeProc xmlns="http://www.portalfiscal.inf.br/nfe"
         xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         versao="4.00">
   <NFe>
   </NFe>
   <protNFe versao="4.00">
      <infProt Id="ID141220260216089">
         <tpAmb>1</tpAmb>
         <verAplic>PR-v4_7_79</verAplic>
         <chNFe>00000000</chNFe>              <---------------- this value 
         <dhRecbto>2022-10-31T08:58:01-03:00</dhRecbto>
         <nProt>141220260216089</nProt>
         <digVal>kkKWL87hgKqmXQ7jL0qbQ2dgL3U=</digVal>
         <cStat>100</cStat>
         <xMotivo>Autorizado o uso da NF-e</xMotivo>
      </infProt>
   </protNFe>
</nfeProc>

I need to create an attribute with evaluateXPath processor to extract this chNFe as text.

Upvotes: 0

Views: 491

Answers (1)

tonykoval
tonykoval

Reputation: 1257

Use a EvaluateXPath processor:

  • Destination: flowfile-attribute
  • Return Type: auto-detect
  • Allow DTD: false
  • chNFe (dynamic): /*:nfeProc/*:protNFe/*:infProt/*:chNFe/text()

Upvotes: 2

Related Questions