Hi,
I am trying to edit an XML file automatically but my regex and shell script knowledge is very limited. I would appreciate your help fellows.
The XML file has this structure:
HTML Code:
<?xml version="1.0" encoding="UTF-8"?>
<map map_file="maps/world.swf" zoom="350%" zoom_x="-115%" zoom_y="-94%" tl_long="-168.49" tl_lat="83.63" br_long="190.3" br_lat="-55.58" >
<areas>
<area zoom="1050.7143%" zoom_x="-633.98%" zoom_y="-540.19%" title="AFGHANISTAN" mc_name="AF"></area>
<area zoom="2992.1429%" zoom_x="-1514.47%" zoom_y="-1098.25%" title="ALAND ISLANDS" mc_name="AX"></area>
...
<area zoom="1071%" zoom_x="-664.6%" zoom_y="-697.61%" title="MALDIVES" mc_name="MV"></area>
<area zoom="366.9853%" zoom_x="-290.73%" zoom_y="-218.45%" title="NAURU" mc_name="NR"></area>
<area title="borders" mc_name="borders" color="#FFFFFF" balloon="false"></area>
</areas>
<movies>
<movie file="home" x="50" y="71" url="!/ammap/ammap_data.xml"></movie>
</movies>
<labels>
<label x="60" y="60" url="!/ammap/ammap_data.xml" remain="true" color_hover="#CC0000" zoom_x="0%" zoom_y="0" zoom="100%">
<text><![CDATA[<b>Back to world map</b>]]></text>
</label>
</labels>
</map>
What I would like to do, is replace each line like:
HTML Code:
<area zoom="1050.7143%" zoom_x="-633.98%" zoom_y="-540.19%" title="NEW ZEALAND" mc_name="AF"></area>
By, the following line, in which :
the country is matched in a token : NEW ZEALAND
partly de-capitalized : New Zealand
a dash is included to replace spaces in multiple-word countries : New-Zealand
and re-used in a an expression as follows:
HTML Code:
<area zoom="1050.7143%" zoom_x="-633.98%" zoom_y="-540.19%" title="NEW ZEALAND" url="http://website.com/w/How-to-Apply-in-New-Zealand?a=w/How-to-Apply-in-New-Zealand" mc_name="NZ"></area>
Thank you for your help with this challenging string manipulation.
Attached is one of the sample files I want make changes in.