The best way of handling this type of problem is using XSLT and a stylesheet.
Here is a stylesheet (file.xsl) which will do what you want:
Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="NAME"/>
<xsl:template match="name">
<name><xsl:value-of select="$NAME"/></name>
</xsl:template>
<xsl:template match="*|text()|@*">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Assuming for the purpose of this example that you want to change "abcd" to "Finnbarr" and that you have xsltproc installed on your system, here is how you would do the transformation together with the resulting output:
Code:
$ xsltproc -param NAME "'Finnbarr'" file.xsl file.xml
<?xml version="1.0"?>
<component>
<name>Finnbarr</name>
<value>1234</value>
</component>
$
Note the double and single quotes around the vale of the NAME parameter. These are required.