2.1.26.46 tree_get_node_by_tagname


Description

It gets the treenode with given tagname

Syntax

TreeNode tree_get_node_by_tagname( const TreeNode & tr, LPCSTR lpcszTagName, bool bRecursive = false, bool bCaseSensitive = false, bool bSkipBranch = false )

Parameters

tr
[input] the tree for search
lpcszTagName
[input] given tagname
bRecursive
[input] if True, will check all nodes, else just check root's tagname
bCaseSensitive
[input] case sensitive
bSkipBranch
[input] skip branch

Return

the root treenode if success, fail will return an invalid treenode

Examples

EX1

void tree_get_node_by_tagname_ex1()
{
	Tree myTree;
	TreeNode tn1, tn2, tn3, tn4, tn5, tn;
       
	tn1 = myTree.AddTextNode("a", "node1", 1);
	tn2 = tn1.AddTextNode("a", "node2", 2);
	tn3 = tn2.AddTextNode("a", "node3", 3);
	tn4 = tn3.AddTextNode("a", "node4", 4);
	tn5 = tn4.AddTextNode("a", "Node1", 5);

	//bCaseSensitive = false && bRecursive = true
	tn = tree_get_node_by_tagname(myTree, tn5.tagName, true, false, false);	
	if( tn )
	{
		out_str("Yes!");
		out_tree(tn);
	}
	else
		out_str("Sorry! Can't find it!");
	
	//bCaseSensitive = true && bRecursive = true
	tn = tree_get_node_by_tagname(myTree, tn5.tagName, true, true, false);	
	if( tn )
	{
		out_str("Yes!");
		out_tree(tn);
	}
	else
		out_str("Sorry! Can't find it!");
}

Remark

See Also

tree_get_node_by_dataid

Header to Include

origin.h

Reference