The file that is given is not valid xml. You have to add opening and closing root tags. Like this:
<xml>
<controller-host></controller-host>
<controller-port></controller-port>
<tier-name></tier-name>
<node-name></node-name>
</xml>
With that input you can use an xml parser like xmlstartlet
to edit the contents:
xmlstarlet ed -O -u //controller-host -v "AppDynamicsHost" \
-u //controller-port -v "80" \
-u //tier-name -v "the hostname" \
-u //node-name -v "tomcat server" file
ed
start editing mode ofxmlstartlet
-O
omit the<?xml version="1.0"?>
declaration-u
update the given xpath-v
set the given value
The output would then be:
<xml>
<controller-host>AppDynamicsHost</controller-host>
<controller-port>80</controller-port>
<tier-name>the hostname</tier-name>
<node-name>tomcat server</node-name>
</xml>
To edit the file directly inplace you can use the -L
flag.