Need to take inputs from a file,then search that set of content from a XML file.In below sample file need to take input (John,MANG,102) from serch_file.txt,then need to search that combination each record H> to /H>) if found need to take the ADR> to /ADR> content from that record(H> to /H>) and write into the output.txt file.
INPUT FILE
serch_file.txt
John,MANG,102
XML FILE
XML_file.xml
<H>
<NAM>John</NAM>
<DEG>DEV</DEG>
<ID>100</ID>
<ADR>
HOME 1,USA
Pin-12345
</ADR>
</H>
<H>
<NAM>John</NAM>
<DEG>ANALIST</DEG>
<ID>101</ID>
<ADR>
HOME 3,USA
Pin-12345
</ADR>
</H>
<H>
<NAM>John</NAM>
<DEG>MANG</DEG>
<ID>102</ID>
<ADR>
HOME 2,UK
Pin-54321
</ADR>
</H>
OUT PUT FILE
output.txt
John,MANG,102
HOME 2,UK
Pin-54321
My Work
IFS=,
while read name deg id
do
cat XML_file.xml
--here difficult to check that combination to each 3 <H> to </H> record
> output.txt
done < serch_file.txt
//H[NAM='John'][DEG='MANG'][ID=102]/ADR. Pretty much every duplicate I linked tells you how to run XPath queries.rs=$'\x01'; fs=$'\x02'; while IFS="$fs" read -r -d "$rs" h nam deg id adr; do [[ $nam = $dest_nam && $deg = $dest_deg && $id = $dest_id ]] && printf '%s\n' "$nam,$deg,$id" "$adr"; done < <(xmlstarlet sel -t -m '//H' -v ./NAM -o "$fs" -v ./DEG -o "$fs" -v ./ID -o "$fs" -v ./ADR -o "$rs"), or such (not tested, edit to taste, requires the values you're searching for to be in thedest_*variables). Again, all the necessary elements are taught in the flagged duplicates.