Edit report at http://bugs.php.net/bug.php?id=52987&edit=1
ID: 52987 Comment by: andre dot boily at mcccf dot gouv dot qc dot ca Reported by: andre dot boily at mcccf dot gouv dot qc dot ca Summary: Losing amperstamp with xml_parse_into_struct function Status: Feedback Type: Bug Package: XML related Operating System: Linux - SUSE PHP Version: 5.2.14 Block user comment: N New Comment: I saw in the snapshot you've send me, the BUG is corrected in version 2.5.15. - Fixed bug #45996 (libxml2 2.7 causes breakage with character data in xml_parse()). (Rob) Thanx! Previous Comments: ------------------------------------------------------------------------ [2010-10-07 04:13:02] ahar...@php.net Please try using this snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows: http://windows.php.net/snapshots/ Works as expected for me on a current 5.2 build: the relevant bit of output is: [3]=> array(4) { ["tag"]=> string(3) "URL" ["type"]=> string(8) "complete" ["level"]=> int(3) ["value"]=> string(37) "http://www.test.com?param1=1¶m2=2" } Note the decoded ampersand in the value. ------------------------------------------------------------------------ [2010-10-04 22:05:58] andre dot boily at mcccf dot gouv dot qc dot ca Description: ------------ Running version: 5.2.14 After a lot of tests and reading, I experimenting a problem since we've upgraded the PHP version from 5.2.6 to 5.2.14 The problem is when i'm trying to put a xml string in a array, i'm loosing the amperstamp (&)characters in the output of xml_parse_into_struct function. Maybe it's a new features that I can't understand, but it look like a Bug. Note: The Bug is in the URL tag in my XML structure. Test script: --------------- <?php $xmlValues = array(); $xmlIndex = array(); $parser = xml_parser_create(""); // Case management option xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 1 ); // White space management option xml_parser_set_option( $parser, XML_OPTION_SKIP_WHITE, 0 ); xml_parser_set_option( $parser, XML_OPTION_TARGET_ENCODING, "UTF-8" ); $data = "<?xml version='1.0' encoding='utf-8'?><COLLECTION><DOCUMENT><TITRE>Some Title</TITRE><URL>http://www.test.com?param1=1&param2=2</URL><DATE>1285352820</DATE></DOCUMENT></COLLECTION>"; xml_parse_into_struct( $parser, $data, $xmlValues, $xmlIndex ); var_dump($xmlValues); ?> Expected result: ---------------- array(6) { [0]=> array(3) { ["tag"]=> string(10) "COLLECTION" ["type"]=> string(4) "open" ["level"]=> int(1) } [1]=> array(3) { ["tag"]=> string(8) "DOCUMENT" ["type"]=> string(4) "open" ["level"]=> int(2) } [2]=> array(4) { ["tag"]=> string(5) "TITRE" ["type"]=> string(8) "complete" ["level"]=> int(3) ["value"]=> string(10) "Some Title" } [3]=> array(4) { ["tag"]=> string(3) "URL" ["type"]=> string(8) "complete" ["level"]=> int(3) ["value"]=> string(36) "http://www.test.com?param1=1&param2=2" } [4]=> array(3) { ["tag"]=> string(8) "DOCUMENT" ["type"]=> string(5) "close" ["level"]=> int(2) } [5]=> array(3) { ["tag"]=> string(10) "COLLECTION" ["type"]=> string(5) "close" ["level"]=> int(1) } } Actual result: -------------- array(6) { [0]=> array(3) { ["tag"]=> string(10) "COLLECTION" ["type"]=> string(4) "open" ["level"]=> int(1) } [1]=> array(3) { ["tag"]=> string(8) "DOCUMENT" ["type"]=> string(4) "open" ["level"]=> int(2) } [2]=> array(4) { ["tag"]=> string(5) "TITRE" ["type"]=> string(8) "complete" ["level"]=> int(3) ["value"]=> string(10) "Some Title" } [3]=> array(4) { ["tag"]=> string(3) "URL" ["type"]=> string(8) "complete" ["level"]=> int(3) ["value"]=> string(36) "http://www.test.com?param1=1param2=2" } [4]=> array(3) { ["tag"]=> string(8) "DOCUMENT" ["type"]=> string(5) "close" ["level"]=> int(2) } [5]=> array(3) { ["tag"]=> string(10) "COLLECTION" ["type"]=> string(5) "close" ["level"]=> int(1) } } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52987&edit=1