ReplaceChild works fine. Without your code (or an explanation of what error you are getting) it is hard to know what is going wrong for you but check the following:
1. You have the parameters the right way round, it is
ReplaceChild(new, old)
2. The new node must be created from the same document
3. The replace child must be done on an ancestor of the old node
One thing is that if you want to rename DETAILS to ITEMDETAILS then you need to copy all the attributes and child nodes across to the new node, otherwise you will get the following:
="1.0"
<Root>
<Header xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<H1>A</H1>
<H2>B</H2>
<H3>C</H3>
<H4>D</H4>
</Header>
<ITEMDETAILS />
</Root>
Which I suspect is not what you want. What you need to do is copy each child element and attribute to the new node, as shown
here[
^]