Help with Script please

I have an xml output like mentioned below:

result="<RETURN status="FAILED" number="5101">Invalid value for 'add_host_ips' : 192.168.1.55 (not assigned to AG owner). IPs do not exist in the license or user account.</RETURN>"

I just want to isolate status="FAILED" and assign failed to a variable.

Seems simple, but i dont know really well scripting hence unable to do it.

Any help would be greatly appreciated.
Thanks in advance.

something like the following, untested, sed regex may need escape fiddling

status=$(echo $return |sed 's/<.+?status="([^"]+)".+>/\1/')

Thanks a lot for your reply, but the code gives the following error

sed: -e expression #1, char 29: invalid reference \1 on `s' command's RHS

thanks in advance.

Try this

sed  's/^.*status="\([^"]*\)".*$/\1/'
FAILED

Sorry guys for the trouble; but there is still an error:

result="<RETURN status="FAILED" number="5101">Invalid value for 'add_host_ips' : 192.168.1.55 (not assigned to AG owner). IPs do not exist in the license or user account.</RETURN>"
sed 's/^.*status="\([^"]*\)".*$/\1/')
echo $status
#out put: 

#<RETURN status=FAILED number=5101>Invalid value for 'add_host_ips' : 192.168.1.55 (not assigned to AG owner). IPs do not exist in the license or user account.</RETURN>

---------- Post updated at 09:57 AM ---------- Previous update was at 09:55 AM ----------

result="<RETURN status="FAILED" number="5101">Invalid value for 'add_host_ips' : 192.168.1.55 (not assigned to AG owner). IPs do not exist in the license or user account.</RETURN>"

status=$(echo $result |sed 's/^.*status="\([^"]*\)".*$/\1/')

echo $status

out put:

<RETURN status=FAILED number=5101>Invalid value for 'add_host_ips' : 192.168.1.55 (not assigned to AG owner). IPs do not exist in the license or user account.</RETURN>

Your assignment of the literal value is not being interpreted the way you think it is, the double quotd are being interpreted by the shell.

Try asssgning the value to result from a process directly, or compare to the snippet below:

result='<RETURN status="FAILED" number="5101">Invalid value for "add_host_ips" : 192.168.1.55 (not assigned to AG owner). IPs do not exist in the license or user account.</RETURN>'
status=$(echo $result|sed 's/^.*status="\([^"]*\)".*$/\1/')
echo $status