/[cvs]/nfo/site/htdocs/inc/xmlcp/xmlcp.php.inc
ViewVC logotype

Contents of /nfo/site/htdocs/inc/xmlcp/xmlcp.php.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations)
Mon Sep 6 01:02:04 2004 UTC (19 years, 11 months ago) by rabit
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +3 -3 lines
U Functions: xmlcp_registertagcallbacks(), xmlcp_xmlp_endelement(): Added support for items w/o end tag.

1 <?php
2 /*------------------------------------------------------------------------------
3 --- www.netfrag.org
4 --- XML content parser functions include file.
5 --------------------------------------------------------------------------------
6 --- rabit, 21:21 26.08.2004
7 --- $$id$$
8 ------------------------------------------------------------------------------*/
9
10 $xmlcp_tagcbfunctions = array();
11 $xmlcp_cdata = '';
12
13 function xmlcp_registertagcallbacks($tagname, $fn_startelement, $fn_endelement = '') {
14
15 global $xmlcp_tagcbfunctions;
16
17 if($tagname && $fn_startelement) {
18
19 $xmlcp_tagcbfunctions[$tagname] = array($fn_startelement, $fn_endelement);
20
21 return true;
22
23 }
24
25 return false;
26
27 }
28
29 function xmlcp_parse($xmldata) {
30
31 $h_cmsparser = xml_parser_create();
32
33 xml_parser_set_option($h_cmsparser, XML_OPTION_CASE_FOLDING, false);
34
35 xml_set_element_handler($h_cmsparser, 'xmlcp_xmlp_startelement', 'xmlcp_xmlp_endelement');
36 xml_set_character_data_handler($h_cmsparser, 'xmlcp_xmlp_characterdata');
37
38 $res = xml_parse($h_cmsparser, $xmldata, true);
39
40 xml_parser_free($h_cmsparser);
41
42 return $res;
43
44 }
45
46 function xmlcp_xmlp_characterdata($h_parser, $cdata) {
47
48 global $xmlcp_cdata;
49
50 $xmlcp_cdata .= $cdata;
51
52 }
53
54 function xmlcp_xmlp_endelement($h_parser, $tagname) {
55
56 global $xmlcp_tagcbfunctions;
57
58 if(isset($xmlcp_tagcbfunctions[$tagname]) && $xmlcp_tagcbfunctions[$tagname][1]) echo $xmlcp_tagcbfunctions[$tagname][1]($h_parser, $tagname);
59
60 }
61
62 function xmlcp_xmlp_startelement($h_parser, $tagname, $attribs) {
63
64 global $xmlcp_tagcbfunctions;
65
66 if(isset($xmlcp_tagcbfunctions[$tagname])) $xmlcp_tagcbfunctions[$tagname][0]($h_parser, $tagname, $attribs);
67
68 }
69
70 //----------------------------------------------------------
71
72 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed