Index: ns_xmlrpc/ns_xml-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/ns_xmlrpc/ns_xml-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ns_xmlrpc/ns_xml-procs.tcl 11 Jul 2001 15:45:49 -0000 1.1 @@ -0,0 +1,70 @@ +# ns_xml-x.tcl 2001 Dave Bauer dave@thedesignexperience.org +# +# handy functions to complement ns_xml module + + +# ns_xml_getElementsByTagName +# duplicate functionality of similar function in TclDOM +# +# create a list of nodes that match a name +# +# Arguments +# +# node node to get children of +# +# name name to look for +# +# Results +# +# returns a list of nodes +# + +proc ns_xml_getElementsByTagName {node name} { + + + set children_list [ns_xml node children $node] + set elements [list] + + foreach child $children_list { + if { [ ns_xml node name $child] == $name } { + lappend elements $child + } + } + + return $elements +} + + +# ns_xml_getChildrenTrim +# +# removes whitespace only nodes from a list of children +# hack because ns_xml doesn't allow you to remove nodes from the tree +# so we get the list and return a list with the whitespace only nodes +# removed +# + +proc ns_xml_getChildrenTrim node { + + set children_list [ns_xml node children $node] + + set new_children {} + foreach child $children_list { + + + if {[ns_xml node type $child] == "cdata_section" && ![string length [string trim [ns_xml node getcontent $child]]]} { + + + } else { + lappend new_children $child + } +} + +return $new_children +} + +proc ns_xml_firstChild node { + + return [lindex [ns_xml_getChildrenTrim $node] 0 ] +} + +