I'd probably pipe the two files and write out the text in between.
Something (very) roughly like this:
var newText = "some new text",
ws = fs.createWriteStream("target.xml"),
rs = fs.createReadStream("file1.xml");
rs.pipe(ws, { end: false });
rs.on('end', function () {
ws.write(newText);
rs = fs.createReadStream("file2.xml");
rs.pipe(ws, { end: false });
rs.on('end', function () {
ws.end();
console.log("Done.");
});
});
Some error checking would be good, but that's the general idea.
--
Martin Cooper
> -Mark Stone
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>