I have an XML data in the following form:
<string name="app_name">my App</string>
<string name="yes">Yes</string>
<string name="no">No</string>
<string name="done">Done</string>
I'm trying to write a Bash script for converting the XML to something like this:
<string comment="for more see http://www.web.com/test/app_name" name="app_name">my App</string>
<string comment="for more see http://www.web.com/test/yes" name="yes">Yes</string>
I did some search and here's what I have found so far.
The code below is making a replacement is every element:
sed -i 's/<string/<string comment=\"for more see http:\/\/www\.web\.com\/test\/\" /g' string.xml
And this expression fetches the name attribute:
Sname=$(sed '/name/s/\(.*name=\)\(.*\)/\2/' string.xml|awk -F\" '{print $2}')
But I have no idea how to merge them.