[...] it seems to me that replacing a part of a XML document (which is what I'm trying to do) should be a straightforward operation for an XML database.
Sure it is. What have your tried so far? XQuery offers (actually too) many ways to do the same thing; you could opt for replacing the $entry variable with the XML fragment in question. Or you could use the replace expression, e.g.
declare namespace atom = 'http://www.w3.org/2005/Atom'; let $old := doc('libx2_feed')/atom:feed/atom:entry[atom:id=$id] let $new := <node>to be added</node| replace node $old with $new
Christian