ben
committed
on 30 May 01

fixed logging to be more configurable within the QD and default to not so verbose.
/tcl/30-xml-utils-procs.tcl (+8 -0)
1 1
2 2 # 50-xml-utils-procs.tcl
3 3 # (ben for OpenACS)
4 4 #
5 5 # This is a set of utilities for dealing with XML in a nice way,
6 6 # using ns_xml. Since ns_xml only offers a very basic interface to
7 7 # accessing XML documents, we add additional functions. As ns_xml gets
8 8 # better, it's perfectly conceivable that these functions will be
9 9 # implemented more efficiently by calling ns_xml more directly.
10 10 #
11 11 # It would be nice if this could be used without the ACS, so we're not
12 12 # using ad_proc constructs for this at this point.
13 13
  14 # Clean stuff up if we have to
  15 # I'm unhappy about this, but there seem to be bugs in the XML parser!! (ben)
  16 proc xml_prepare_data {xml_data} {
  17     # remove comments
  18     regsub -all {<!--[^>]*-->} $xml_data "" new_xml_data
  19     return $new_xml_data
  20 }
  21
14 22 # Find nodes of a parent that have a given name
15 23 proc xml_find_child_nodes {parent_node name} {
16 24     set children [ns_xml node children $parent_node]
17 25
18 26     set list_of_appropriate_children [list]
19 27
20 28     foreach child $children {
21 29         if {[ns_xml node name $child] == $name} {
22 30             lappend list_of_appropriate_children $child
23 31         }
24 32     }
25 33
26 34     return $list_of_appropriate_children
27 35 }
28 36