I have a xml file emp.xml
<?xml>
<employee name="abc">ABC</employee>
<employee name="def">DEF</employee>
<!-- abc@gmail.com
this comment is added
to <employee name="gh">
</employee>
-->
?>
I want to delete some employee details from this file. Employee details to be deleted are mentioned in other file delemp.txt abc gh
while read line
do
i=\"$line\"
echo $i
find . -name "emp.xml" -type f | xargs sed -i -e '/employee name='$i'/,/<\/employee>/d'
done < delemp.txt
I am reading delemp.txt and getting employee details to be deleted and searching for employee name= and employee end tag but this code is not working
Even if I try
sed -i '/employee name=\"abc\"/,/<\/employee>/d' emp.xml
It is deleting first 2 lines i.e name="abc" and "def"