/[drupal]/contributions/modules/legislature/xml.inc
ViewVC logotype

Contents of /contributions/modules/legislature/xml.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Tue Jun 2 00:06:57 2009 UTC (5 months, 3 weeks ago) by drumm
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +3 -1 lines
File MIME type: text/x-php
Removing db_num_rows()
1 <?php
2 // $Id: xml.inc,v 1.2 2007/11/27 05:30:11 drumm Exp $
3
4 /**
5 * Parse a string of XML into a callback function.
6 *
7 * This is deprecated. Use SimpleXML.
8 */
9 function legislature_xml_parse($data, $callback, $setup_arguments = NULL) {
10 $return = TRUE;
11 $parser = drupal_xml_parser_create($data);
12 legislature_xml_set_callback($parser, $callback);
13 if (!is_null($setup_arguments)) {
14 $callback('setup', $parser, $setup_arguments);
15 }
16 xml_set_element_handler($parser, 'legislature_xml_start', 'legislature_xml_end');
17 xml_set_character_data_handler($parser, 'legislature_xml_data');
18 if (!xml_parse($parser, $data, 1)) {
19 $return = FALSE;
20 }
21 xml_parser_free($parser);
22
23 return $return;
24 }
25
26 function legislature_xml_start($parser, $name, $attributes) {
27 $callback = legislature_xml_get_callback($parser);
28 $callback('start', $parser, $name, $attributes);
29 }
30
31 function legislature_xml_end($parser, $name) {
32 $callback = legislature_xml_get_callback($parser);
33 $callback('end', $parser, $name);
34 }
35
36 function legislature_xml_data($parser, $data) {
37 $callback = legislature_xml_get_callback($parser);
38 $callback('data', $parser, $data);
39 }
40
41 /**
42 * Set the XML callback for a given parser.
43 */
44 function legislature_xml_set_callback($parser, $callback = NULL) {
45 static $callbacks = array();
46
47 if (!is_null($callback)) {
48 $callbacks[''. $parser] = $callback;
49 }
50
51 return $callbacks[''. $parser];
52 }
53
54 /**
55 * Return the XML callback for a given parser.
56 */
57 function legislature_xml_get_callback($parser) {
58 return legislature_xml_set_callback($parser);
59 }

  ViewVC Help
Powered by ViewVC 1.1.2