Index: openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl,v diff -u -r1.70.2.3 -r1.70.2.4 --- openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 25 Mar 2004 15:59:30 -0000 1.70.2.3 +++ openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 18 May 2004 16:23:46 -0000 1.70.2.4 @@ -4188,6 +4188,74 @@ return $result } + +ad_proc -public xml_get_child_node_attribute_by_path { + node + path_list + attribute_name +} { + + Return the attribute of a child node down a give path from the current node. + + <p> + + Example:<pre> + set tree [xml_parse -persist " +<enterprise> + <properties> + <datasource>University of Durham: SIS</datasource> + <target>University of Durham: LMS</target> + <type>CREATE</type> + <datetime>2001-08-08</datetime> + </properties> + <group recstatus = "1"> + <sourcedid> + <source>University of Durham</source> + <id>CS1</id> + </sourcedid> + <grouptype> + <scheme>University of Durham</scheme> + <typevalue level = "2"/> + </grouptype> + + ..... + + </group> +</enterprise> + +"] + set root_node [xml_doc_get_first_node $tree] + set group_node [xml_node_get_children_by_name $root_node "group"] + set typevalue [xml_get_child_node_attribute_by_path $group_node {grouptype typevalue} "level"] + + @param node The node to start from + @param path_list List of the node to try, e.g. + { grouptype typevalue }. + @param attribute_name Attribute name at the very end of the very botton of the tree route at path_list. + + @author Rocael Hernandez (roc@viaro.net) + +} { + + set attribute {} + set current_node $node + foreach element_name $path_list { + set current_node [xml_node_get_first_child_by_name $current_node $element_name] + if { [empty_string_p $current_node] } { + # Try the next path + break + } + } + + if { ![empty_string_p $current_node] } { + set attribute [xml_node_get_attribute $current_node $attribute_name ""] + } + + return $attribute + +} + + ad_proc -public ad_generate_random_string {{length 8}} { Generates a random string made of numbers and letters } {