We need a function to evaluate XPATH string into and get the text from that node. For eg, given the below XPATH in the input file:

 

/X12/TS_204/GROUP_3/GROUP_4/N4/N401/text() ="TORREON" 

In Xquery code:

let $N401 := "/X12/TS_204/GROUP_3/GROUP_4/N4/N401"

return evaluate($doc, N401) 

Result:: We will get "TORREON" from the output.