Thanks very much for looking into this. Yes I understand it has multiple issues and I am still trying to evolve on scripting so I sure WILL take your advice in upcoming posts
I have updated my question a trimmed version of xml although it contains all the necessary input required for the script.
if BRLAN = y then first the script should search for CoreLanNum $n. and the loop should run as many times as $n and should match BR_IP with CorLanNum_IP and store the value in a array.
If this array is empty run next for loop and search of CoreVlanNum $n and the script should again search for CoreVlanIP with BR_IP and map it with equivalent netmask.