How to pass values to XML file trough shell script?

Asked By 80 points N/A Posted on -
qa-featured

How do I pass values to an Extensible Markup Language (XML) file from shell script? I want to pass value to an XML file from shell script so as to replace values in some of the tag, but the results I have been getting is not what I intend. How do I use the replace command in the script? N:B the values to be pass are likely to change?

SHARE
Answered By 0 points N/A #187581

How to pass values to XML file trough shell script?

qa-featured
Hi Justin,
 
The values from a shell script can be passed to an XML file with a "sed" command. The values to be passed are likely to be changed based on the values defined by you for that particular variable. The following is an instance of a sed command usage.
 
$ CLIENT_ID=255
$ echo "<clientId>000</clientId>" | sed "s/<clientId>[0-9]*/<clientId>${CLIENT_ID}/"
<clientId>255</clientId>
 
Regards,
Anyet

Related Questions