X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=c%2B%2B0x%2Fxml-template.cpp;h=c2b62cd77ecbb6da8441e938809bb4042120c453;hb=83a41af3311ec494205205ec093ffff0aad56fd0;hp=a6a7316846db452bdf03e364f9f81a830486aa72;hpb=34c73f84835f00b960b1bde0aca69588230791a4;p=xml-template diff --git a/c++0x/xml-template.cpp b/c++0x/xml-template.cpp index a6a7316..c2b62cd 100644 --- a/c++0x/xml-template.cpp +++ b/c++0x/xml-template.cpp @@ -16,6 +16,7 @@ void clean_node(xmlNode *node) xmlNode *frag = xmlNewDocFragment(node->doc); xmlReplaceNode(node, frag); frag->children = node->children; + frag->last = node->last; } } @@ -27,7 +28,7 @@ Replace::Replace(const string &str) : str(str) {} void Replace::process(xmlNode *node, bool clean) { - node->children = xmlNewTextLen(reinterpret_cast(str.data()), str.size()); + xmlNodeSetContentLen(node, reinterpret_cast(str.data()), str.size()); if (clean) { clean_node(node); } @@ -61,7 +62,10 @@ void Clone::process(xmlNode *node, bool clean) } } - node->children = NULL; + xmlFreeNodeList(node->children); + node->content = NULL; + node->children = node->last = NULL; + for (auto child : new_nodes) { xmlAddChild(node, child); }