2.2.3.17.9 TreeNode::FindNodeByAttributeFindNodeByAttribute
Description
Find a node from a tree by the AttributeName with matching integer value.
Find a node from a tree by the AttributeName with matching string value.
Syntax
TreeNode FindNodeByAttribute( LPCSTR AttributeName, int nVal, BOOL bRecursive = TRUE )
TreeNode FindNodeByAttribute( LPCSTR AttributeName, LPCSTR lpcszValue, BOOL bRecursive = TRUE, BOOL bCaseSensitive = FALSE )
Parameters
- AttributeName
- [input] String representing attribute name of the node whose integer value needs to be compared
- nVal
- [input] the value to compare with
- bRecursive
- [input] true, go through all the tree nodes; false, just go through the Children
- AttributeName
- [input] String representing attribute name of the node whose string value needs to be compared
- lpcszValue
- [input] the value to compare with
- bRecursive
- [input] true, go through all the tree nodes; false, just go through the Children
- bCaseSensitive
- [input] true will take care of lpcszValue's case; else false
Return
The first node which has an attribute AttributeName name with matching value.
The first node which has an attribute AttributeName name with matching string value.
Examples
EX1
#define ATTRIB_NAME "AttribID"
void TreeNode_FindNodeByAttribute_ex1()
{
Tree tr;
TreeNode tn1, tn2, tn3;
tn2 = tr.AddTextNode("abc", "node2", 2);
tn2.SetAttribute(ATTRIB_NAME, 2);
tn3 = tn2.AddTextNode("efg", "node3", 3); //tn3 is added to tn2 as its child
tn3.SetAttribute(ATTRIB_NAME, 3);
tn1 = tn2.FindNodeByAttribute(ATTRIB_NAME, 3); //now tn1 is equal to tn3
out_tree(tn1);
}
EX2
#define ATTRIB_NAME "AttribID"
void TreeNode_FindNodeByAttribute_ex2()
{
Tree tr;
TreeNode tn1, tn2, tn3;
tn2 = tr.AddTextNode("abc", "node2", 2);
tn2.SetAttribute(ATTRIB_NAME, "Hello");
tn3 = tn2.AddTextNode("efg", "node3", 3); //tn3 is added to tn2 as its child
tn3.SetAttribute(ATTRIB_NAME, "Hi");
tn1 = tn2.FindNodeByAttribute(ATTRIB_NAME, "Hi"); //now tn1 is equal to tn3
out_tree(tn1);
}
Remark
See Also
Header to Include
origin.h
|