As the node being replaced has been added with XMLNode::add_child_nocopy the node also needs to be deleted or a memory leak occurs.