Replaces a node in the tree.
BOOL Replace( TreeNode & tn, BOOL bDeep = TRUE, BOOL bKeepTagName = FALSE, BOOL bKeepAttributes = FALSE )
TRUE if the node is successfully replaced; FALSE otherwise
EX1
void TreeNode_Replace_ex1() { Tree tr; TreeNode tn1 = tr.AddNumericNode(123, "node1", 1); TreeNode tn2 = tr.AddTextNode("abc", "node2", 2); TreeNode tn21 = tn2.AddTextNode("dfg", "node3", 3); TreeNode tn211 = tn21.AddNumericNode(456, "node4", 4); out_tree(tr); /* tr / \ node1(123) node2(abc) | node3(dfg) | node4(456) */ // bDeep is TRUE, tn1 will be replaced by tn3 and its children. // bKeepTagName is TRUE, tagname of tn1 will be keep. // bKeepAttributes is FALSE, tn1's ID will be replaced by tn3's. bool flag = tn1.Replace(tn21, TRUE, TRUE, FALSE); if(flag) printf("node3 successfully replaced \n"); out_tree(tr); int ID; if ( tn1.GetAttribute("NodeID", ID) ) printf("the attribute ID %d", ID); }
origin.h