TreeNode::InsertNode

Description

Insert a child node.

Syntax

TreeNode InsertNode( const TreeNode & trBefore, LPCSTR lpcszTagName, int nChildID = -1 )

Parameters

trBefore
[input] The node before which a new node has to be inserted
lpcszTagName
[input] Insert node name
nChildID
[input] Insert node ID

Return

The inserted node

Examples

EX1

void TreeNode_InsertNode_ex1()
{
    Tree myTree;
    TreeNode tn1, tn2, tn3;
    tn1 = myTree.AddNumericNode(123, "node1", 1);            
    tn2 = myTree.AddTextNode("abc", "node2", 2);
    tn3 = tn2.AddTextNode("abc", "node3", 2);
    tn3 = tn2.InsertNode(tn3, "abcd");

    out_tree(myTree);
    
    bool flag1 = tn3.Replace(tn1, TRUE);
    if(flag1) printf("node3 successfully replaced \n");
    out_tree(myTree);
    
}

Remark

See Also

TreeNode::AddNode, TreeNode::Replace, TreeNode::AddTextNode, TreeNode::AddNumericNode

header to Include

origin.h