Hi guys,

When I thought I was almost finished I stumbled upon a problem writing my bash script.

Let me explain.. I've got two files, newdata.txt and data.xml

The file newdata.txt looks similar to this:

<url>http://example.com/1234</url><info>63113</info>
<url>http://example.com/3253</url><info>245121</info>
<url>http://example.com/3454</url><info>212512</info>
<url>http://example.com/6364</url><info>2531</info>
<url>http://example.com/3582</url><info>2352</info>

The file data.xml:

.....
<url>http://example.com/1234</url>
.....
<url>http://example.com/3253</url>
.....
<url>http://example.com/3454</url>
.....
<url>http://example.com/6364</url>
.....
<url>http://example.com/3582</url>
.....

What I want to do is replace the line in data.xml with the corresponding data from newdata.txt.

As you can see from the structure, line by line replacement is not an option.

My first solution to the problem was something like this.

1. Read newdata.txt line by line.
2. Save the line into two variables, $newdata (<url>http://example.com/1234</url><info>2482</info>) and $olddata (<url>http://example.com/1234</url>)
3. Do a sed replace $olddata with $newdata on data.xml

And there is the problem, is it even possible to 1. direct data from sed into a variable and 2. use variables with sed?

Everything I've done up to this point is part of a bash script so I would really appreciate any suggestions on how to achieve this without writing a new program from the beginning.

Hopefully I made myself clear enough, been sitting with this the entire evening until I crash landed with this problem an hour ago. So I'm a bit nackerd.

Cheers