Thanks a lot RudiC for great code. I was egarly waiting for the same post reply. Could you please explain it a bit, it will help us to improve our skills.
awk '/<nam>/ {L=1} # if a line contains <nam>, keep that fact in variable L
/<a1>/ {L=0} # if then <a1> occurs, no action necessary, reset L
/<\/var>/ && L {print "<a1>.</a1>"} # if end of section and L still set, print missing string.
# you might want to reset L as well to be on the safe side
1 # print normal lines from file
' file