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.73 -r1.74 --- openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 27 Apr 2004 11:16:52 -0000 1.73 +++ openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 18 May 2004 16:43:35 -0000 1.74 @@ -4192,6 +4192,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. + +

+ + Example:

+    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
 } {