void osync_xmlfield_adopt_xmlfield_after_field(OSyncXMLField *xmlfield, OSyncXMLField *to_link) { osync_assert(xmlfield); osync_assert(to_link); osync_xmlfield_unlink(to_link); xmlDOMWrapAdoptNode(NULL, to_link->node->doc, to_link->node, xmlfield->node->doc, xmlfield->node, 0); xmlAddNextSibling(xmlfield->node, to_link->node); to_link->next = xmlfield->next; to_link->prev = xmlfield; if(xmlfield->next) xmlfield->next->prev = to_link; else ((OSyncXMLFormat *)xmlfield->node->doc->_private)->last_child = to_link; xmlfield->next = to_link; ((OSyncXMLFormat *)xmlfield->node->doc->_private)->child_count++; }
// MW-2014-06-12: [[ Bug 12628 ]] Use Remote operation to copy the root out of the new document. bool CXMLElement::MoveRemoteElement(CXMLElement *p_element, bool p_sibling, bool p_before) { // DOMWrapAdoptNode only allows you to move a node to under a parent, so first // we compute the parent node. In non-sibling mode, this is the parent node. In sibling // mode the parent of this is the parent node. xmlNodePtr t_parent; t_parent = element; if (p_sibling) t_parent = t_parent -> parent; // If this has no parent then badness. if (t_parent == NULL) return false; // Now make our doc tree adopt the source node. if (xmlDOMWrapAdoptNode(NULL, p_element -> element -> doc, p_element -> element, element -> doc, t_parent, 0) != 0) return false; // Now that p_element is in this's xmlTree we can use MoveElement to place it appropriately. return MoveElement(p_element, p_sibling, p_before); }