I have an XML file containing some data and i want to extract it, but the specific issue in my file is that the data is repeated some times like the following example :
the idea is to select (or extract) X and Z for a specific subsection only, note here that the number of subsection is changing frequently, (grep didn't work).
SECT="subsection1"
sed -n "/<$SECT>/,/<\\\\$SECT>/ p" data.xml | sed '1d;$d' >temp
while read L
do
eval "$L"
done < temp
echo "X='$X' - Y='$Y' - Z='$Z'"
I'd like to find a way without temp file, but piping to ta "while read" loop creates a subshell so the variables aren't availaible out of the loop.
I saw something about that in a previous post but don't remember the title...