From: sgunderson@bigfoot.com <> Date: Sat, 24 Sep 2011 11:27:32 +0000 (+0200) Subject: In the C++11 version, fix a bug with node removal that would cause an inconsistent... X-Git-Url: https://git.sesse.net/?p=xml-template;a=commitdiff_plain;h=bec181161e7f718c8e15c0bbc0b116b697a696f9 In the C++11 version, fix a bug with node removal that would cause an inconsistent tree. For extra bonus, we do not need document fragments anymore. --- diff --git a/c++11/xml-template.cpp b/c++11/xml-template.cpp index 503e5e3..4f0c9fe 100644 --- a/c++11/xml-template.cpp +++ b/c++11/xml-template.cpp @@ -14,12 +14,11 @@ void clean_node(xmlNode *node) } if (node->ns != NULL && strcmp(reinterpret_cast(node->ns->href), "http://template.sesse.net/") == 0) { - xmlNode *frag = xmlNewDocFragment(node->doc); - xmlReplaceNode(node, frag); - frag->children = node->children; - frag->last = node->last; + while (node->children != NULL) { + xmlAddPrevSibling(node, node->children); + } - node->children = node->last = NULL; + xmlUnlinkNode(node); xmlFreeNode(node); } }