php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2331 XML function handlers and tagname...
Submitted: 1999-09-20 03:54 UTC Modified: 1999-09-25 11:58 UTC
From: bago at datasail dot net Assigned:
Status: Closed Package: Other
PHP Version: 4.0 Latest CVS (20/09/1999) OS: FreeBSD 3.2
Private report: No CVE-ID: None
 [1999-09-20 03:54 UTC] bago at datasail dot net
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('&lt;'.$GLOBALS['tagname'][$GLOBALS['level']].'&gt;');
 }

 function XMLFend($parser, $tgname) {
  $GLOBALS['level']--;
  print('&lt;/'.$GLOBALS['tagname'][$GLOBALS['level']].'&gt;');
 }
 
 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');
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-09-25 11:58 UTC] thies at cvs dot php dot net
seems to be fixed in lastest CVS (just checked)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 04:01:38 2024 UTC