XML file parsing using script

Hi
I need some help with XML file parsing. I have an XML file with the below tag,
I need a script to identify the value of srvcName which is this case is "AAA srvc name". I need to put contents of this value which is AAA srvc and name into different variables using an array and then reformat it and put it into a different variable, in this case lets say RESULT. RESULT should look like "AAA\ srvc\ name"

<platform type="windows" startMenuName="AAA" startMenu="BBB.ico"  addRemoveName="AAA" addRemoveIcon="BBB.ico"
srvcName="AAA srvc name"
 />

What I am trying to do is to retrieve values from a source XML file and write the contents of the value into a target XML file using a shell script. In the target XML file I want to replace lets say a value XXX with "AAA srvc name". Thanks.

what shell?
what did you try so far?

sh or bash. I have attempted to search and retrieve the contents of the string. I need some leads in what I can use to split the string, put it into an array and reformat it. Thx

I'd use sed:

var=$(sed -n 's/srvcName="\([^"]*\)"/\1/p' source.xml)
sed 's/srvcName="XXX"/srvcName="'"$var"'"/' target.xml

you can use perl module XML::Reader.

So if I do this I do not need to split the string? Using this method does it replacing the target with the string (with spaces), can you explain the sed command? Thanks.

var=$(sed -n 's/srvcName="\([^"]*\)"/\1/p' source.xml)

I have changed the above command to the below to get thsi working.

var=`sed -n 's/serviceName="\([^"]*\)"/\1/p' name.xml`

I am running into the below error while trying the command you posted
./test.sh: syntax error at line 98: `var=$' unexpected

Also can someone explain the command
var=`sed -n 's/serviceName="\([^"]*\)"/\1/p' name.xml`

Thanks.