From bec181161e7f718c8e15c0bbc0b116b697a696f9 Mon Sep 17 00:00:00 2001 From: "sgunderson@bigfoot.com" <> Date: Sat, 24 Sep 2011 13:27:32 +0200 Subject: [PATCH] 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. --- c++11/xml-template.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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); } } -- 2.39.2