|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-03-03 19:46 UTC] requinix@php.net
-Status: Open
+Status: Verified
[2015-03-03 19:46 UTC] requinix@php.net
[2015-03-04 08:24 UTC] nadavvin at gmail dot com
[2015-05-27 17:49 UTC] cmb@php.net
-Status: Verified
+Status: Duplicate
-Assigned To:
+Assigned To: cmb
[2015-05-27 17:49 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 00:00:02 2025 UTC |
Description: ------------ when remove, new lines and tab from the following XML, it lost tag name in php > 5.2 instead of "item" appear "0". test and failed in php 5.5.3 (linux), 5.6.6(windows) work on: php 5.2 windows There is also difference between 5.5.3 to 5.6.6 (parse wrong in different ways) Test script: --------------- <?php $a = '<?xml version="1.0" encoding="UTF-8"?> <root a="b"> <row b="y"> <item s="t" /> </row> <row p="c"> <item y="n" /> </row> </root>'; $simple_xml = @simplexml_load_string($a); print_r($simple_xml); $b = str_replace( array("\n", "\r", "\t"), "", $a ); var_dump($b); $simple_xml = @simplexml_load_string($b); print_r($simple_xml); Expected result: ---------------- SimpleXMLElement Object ( [@attributes] => Array ( [a] => b ) [row] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [b] => y ) [item] => SimpleXMLElement Object ( [@attributes] => Array ( [s] => t ) ) ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [p] => c ) [item] => SimpleXMLElement Object ( [@attributes] => Array ( [y] => n ) ) ) ) ) Actual result: -------------- 5.6.6: SimpleXMLElement Object ( [@attributes] => Array ( [a] => b ) [row] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [b] => y ) [0] => SimpleXMLElement Object ( [@attributes] => Array ( [s] => t ) ) ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [p] => c ) [item] => SimpleXMLElement Object ( [@attributes] => Array ( [y] => n ) ) ) ) ) 5.5.3 SimpleXMLElement Object ( [@attributes] => Array ( [a] => b ) [row] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [b] => y ) [0] => SimpleXMLElement Object ( [@attributes] => Array ( [s] => t ) ) ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [p] => c ) [0] => SimpleXMLElement Object ( [@attributes] => Array ( [y] => n ) ) ) ) )