ID:               34598
 User updated by:  priit at ww dot ee
 Reported By:      priit at ww dot ee
-Status:           Open
+Status:           Bogus
 Bug Type:         Feature/Change Request
 Operating System: windows xp
 PHP Version:      5.0.5
 New Comment:

...


Previous Comments:
------------------------------------------------------------------------

[2005-09-22 15:15:04] priit at ww dot ee

Description:
------------
XML parser adds everything between the end of tag until start of next
tag to next tag's value. Yes, I can use trim() to fix this, but it
still doesnt feel right and more like workaround to fix sloppy parsing
error/bug.

Reproduce code:
---------------
<?php
$inputxml = '<?xml version="1.0" encoding="ISO-8859-1"?>
<info>
  <aaa>111</aaa>
     <ccc>222</ccc>
   <bbb>333</bbb>
</info>
';
function startElement($parser, $name, $attrs) { $GLOBALS['temp_name'] =
$name; }
function endElement($parser, $name) { if($GLOBALS['temp_name']==$name)
$GLOBALS['moodul'] .= "(".$GLOBALS['temp_name']." :
'".$GLOBALS['temp_value']."')\n"; $GLOBALS['temp_value'] = ''; }
function characterData($parser, $data) { $GLOBALS['temp_value'] .=
$data; }
$moodul = htmlspecialchars($inputxml)."\n\n";
$temp_value='';
$xml_parser = xml_parser_create('ISO-8859-1');
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
if(!xml_parse($xml_parser, $inputxml)) {
        die(sprintf("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);
echo '<PRE>'.$moodul.'</PRE>';
?>

Expected result:
----------------
(AAA : '111')
(CCC : '222')
(BBB : '333')

Actual result:
--------------
(AAA : '
  111')
(CCC : '
     222')
(BBB : '
   333')


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=34598&edit=1

Reply via email to