I need to replace the versionName in a xml file from a shell script using sed.
Considering the nature of xml and the version number, it is actually very safe to use a simpler command:
sed -i '/versionName/s/".*"/"NEW VERSION NAME"/' AndroidManifest.xml
P.S. in my opinion, it is very important to be able to simplify your shell script based on specific circumstances and reasonable assumptions.