|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[1999-09-25 11:58 UTC] thies at cvs dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 13 20:00:01 2025 UTC |
try this code with a valid default.xml with some xml code. it works fine with php3 and not with php4.... i get it to work with php4 too by adding " to $tgname as in the commented line. i think it's a bug.... or it should be documented in the incompatibility list... <? $level = 0; $tagname = array(); function XMLFstart($parser, $tgname, $attrs) { $GLOBALS['level']++; $GLOBALS['tagname'][$GLOBALS['level']] = $tgname; # $GLOBALS['tagname'][$GLOBALS['level']] = "$tgname"; print('<'.$GLOBALS['tagname'][$GLOBALS['level']].'>'); } function XMLFend($parser, $tgname) { $GLOBALS['level']--; print('</'.$GLOBALS['tagname'][$GLOBALS['level']].'>'); } function XMLFparse($file) { $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "XMLFstart", "XMLFend"); xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true); $fp = fopen($file, "r"); while ($data = fread($fp, filesize($file))) { if (!xml_parse($xml_parser, $data, feof($fp))) { die(sprintf("<BR><BR>XML error: %s at line %d",xml_error_string(xml_get_error_code($xml_parser)),xml_get_current_line_number($xml_parser))); } } xml_parser_free($xml_parser); fclose($fp); } XMLFparse('./default.xml'); ?>