appending content in a xml file

Please help me on this.....

i have a file which has following content:
<IPCoreProducerConfig>
<Producer>
<config>
<key>machineId</key>
<value>machine1</value>
</config>
<config>
<key>Producer Type</key>
<value>Breakout</value>
</config>
<config>
<key>Protocol</key>
<value>SIP</value>
</config>
</Producer>
</IPCoreProducerConfig>

i want to append same thing again so that the content of file looks like:
<IPCoreProducerConfig>
<Producer>
<config>
<key>machineId</key>
<value>machine1</value>
</config>
<config>
<key>Producer Type</key>
<value>Breakout</value>
</config>
<config>
<key>Protocol</key>
<value>SIP</value>
</config>
</Producer>
<Producer>
<config>
<key>machineId</key>
<value>machine1</value>
</config>
<config>
<key>Producer Type</key>
<value>Breakout</value>
</config>
<config>
<key>Protocol</key>
<value>SIP</value>
</config>
</Producer>
</IPCoreProducerConfig>

It may help your need...

#below one is for declaring variable
#-------------------------
v=`sed '/<\IPCoreProducerConfig\>\|<\/IPCoreProducerConfig\>/d' input.filename`

#creating required outputfile
#--------------------------
echo "<IPCoreProducerConfig>" > output.lst
cat input.filename|sed /<\IPCoreProducerConfig\>\|<\/IPCoreProducerConfig\>/d' >> output.filename
echo $v >> output.filename
echo "</IPCoreProducerConfig>" >> output.filename

THanks
Sha

when i am trying to above ..it is not appending

Hi Aditya,

Are you getting any errors when you run above commands..

what was the repsonse that you got..

Thanks
Sha

Another approach with awk, read the file twice, skip the last line the first time and the first line the second time:

awk '
/<\/IPCoreProducerConfig>/ && NR==FNR{next}
/<IPCoreProducerConfig>/ && NR!=FNR{next}
1' file file

Regards