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 && $fn_endelement) { |
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_xmlpage2html($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])) 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 |
?> |