I have an XML file with the following structure:
<root>
<station name = "insert_text"/>
<station name = "insert_text"/>
<station name = "insert_text"/>
</root>
I wanted to replace the text "insert_text" with the values from a text file which looks like:
Station1
Station2
Station3
After reading the input file above, the generated XML file should look like:
<root>
<station name = "Station1"/>
<station name = "Station2"/>
<station name = "Station3"/>
</root>
The script I now use is as follows and it replaces all the 3 lines only with 'Station1'.
while read a
do
sed -i -e "s/insert_text/$a/g" filename.xml
done<inputfile.txt
What should I change in order to replace each of the lines in the XML file with different texts?