I have a header XML node like <Fund
and Footer node which is </Fund>
, so I wrote something like this to retrieve the message associated with this ID
Every XML has a id "33969871" (refer script below)
Provided I give the ID and run this (bash) it should find the ID and traverse back to the top of the message(i,e - <Fund
and then to the bottom of the message (i.e </Fund>
) and the output should that XML
Input file
<Fund LastUpdate="2017-05-23T10:32:53.563000000">
<ID>13779321</ID>
</Fund>
<Fund LastUpdate="2017-05-23T10:32:53.563000000">
<ID>13779322</ID>
</Fund>
<Fund LastUpdate="2017-05-23T10:32:53.563000000">
<ID>13779323</ID>
</Fund>
My awk command
/usr/xpg4/bin/awk '/\<Fund/{flag=1;found=j=0; delete a}
flag{a[++j]=$0} /'33969781'/ && flag{found=1}
/\<\/Fund>/{flag=0 # Ending pattern & found show our array
if(found){for (i=1;i<=j;i++){
print a[i]}}}' ABC_866.xml
But I do not get the results.