2.1.26.42 tree_get_node_by_nodeid


Description

Walk all tree nodes and get the tree node with special node id

Syntax

TreeNode tree_get_node_by_nodeid( TreeNode & trSource, int nNodeD, int nSeacherLevel = 0 )

Parameters

trSource
[input] the tree node to walk
nNodeD
[input] Data ID, saved in STR_ID_ATTRIB attribute
nSeacherLevel
[input] indicate the number of search level

Return

tree node with specail node id.

Examples

EX1

void tree_get_node_by_nodeid_ex1()
{
	Tree trTest;
	TreeNode tn1, tn2;
	tn1 = trTest.AddTextNode("node 1", "Node1", 1);
	tn2 = trTest.AddTextNode("node 2", "Node2", 2);
	TreeNode tn1_1, tn1_2;
	tn1_1 = tn1.AddTextNode("node 1.1", "Node1.1", 3);
	tn1_2 = tn1.AddTextNode("node 1.2", "Node1.2", 4);
	TreeNode tn1_1_1, tn1_1_2;
	tn1_1_1 = tn1_1.AddTextNode("node 1.1.1", "Node1.1.1", 5);
	tn1_1_2 = tn1_1.AddTextNode("node 1.1.2", "Node1.1.2", 6);
	
	TreeNode tnRet = tree_get_node_by_nodeid(trTest, 3, 2);
	if( tnRet )
	{
		out_str("Yes!");
		out_tree(tnRet);
	}
	else
		out_str("Sorry! Can't find it");
}

Remark

See Also

tree_get_node_by_dataid

Header to Include

origin.h

Reference