How can i use sed to replace a keyword in an xml file?

Hello Unix gurus!

I'm a unix newbie. Can I use sed to replace a keyword in an xml file and convert this keyword with an output of a unix cat command?

for example: <test>keyword</test>
and temp.txt = hello!

I would like to replace "keyword" with the output of "cat temp.txt".

I think it is possible using sed. Please help!

l'll appreciate the help bigtime! TIA! :smiley:

sed s/keyword/`cat temp.txt`/ xml_file

wow! that was quick. thanks a bunch palanisvr!

follow up question: how about if i wanted to replace multiple keywords?

example: <test>keyword1</test>
<test>keyword2</test>
<test>keyword3</test>

         temp1=hello!
         temp2=hi!
         temp3=whoa!

TIA!

use XML parsers, where you get the tree node and modifying values is handy

for ex:

XML::Twig

---------- Post updated at 04:53 PM ---------- Previous update was at 04:52 PM ----------

sir i tried this but resulted to an error:

sed s/kw01/`cat fatal_alerts.txt`/ template.xml > new.xml
sed: command garbled: s/kw01/

what could be wrong? I tried doing a similar command and does not report any error:
bash-2.05$ sed s/dirk/`cat g`/ r.txt > new.txt
bash-2.05$ cat new.txt
win nowitzki
bash-2.05$ cat r.txt
dirk nowitzki

PLEASE HELP! :frowning:

I think file "fatal_alerts.txt" may have multiple line of strings .

Yes sir it has multiple string. So that must be causing it to be garbled. Is there anyway to replace the keyword with the contents of fatal_alerts.txt?? Please help. :frowning:

fatal_alerts.txt contents:

RAISEDATTIME
--------------------
DESCRIPTION
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
18-APR-2011 06:20:32
Fatal error in Application GATE:
<Error code: 68
Caught by: CTCS_BatchSchedulerBO.HandleException
Raise by: CTCS_FTOServerBTM.ValidateMessageCount()
Message: For Interface: FTO:1315001 in File : 190107079531.txt
File Message Count Mismatch. File reported count: 447 actual message count 797.>