|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-04-23 13:53 UTC] idefaye at gmail dot com
[2015-03-11 17:24 UTC] idefaye at gmail dot com
[2015-03-11 18:01 UTC] idefaye at gmail dot com
-Summary: Inconsistent parsing of Nodes w/o linefeed
+Summary: Regression: Inconsistent parsing of Nodes w/o
linefeed
[2015-03-11 18:01 UTC] idefaye at gmail dot com
[2015-05-27 17:48 UTC] cmb@php.net
-Status: Open
+Status: Duplicate
-Assigned To:
+Assigned To: cmb
[2015-05-27 17:48 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 02:00:02 2025 UTC |
Description: ------------ I was not able to find an existing claimed bug, hope I am not declaring it double. Environment : 5.4.27nts under windows7 and IIS If an xml node contains only one child-node with attributes, no values, we get a results inconsistent results depending if the XML file is formatted or not: linefeed are present or not. The one with linefeed is consistent with the rest, but if it is compressed, then we get a different result. For an example, here is a quick XML, note that linefeed do matter: <?xml version="1.0" encoding="UTF-8"?> <aa> <bs> <b>b</b> </bs> <cs><c>b</c></cs> <ds><d id="d"></d></ds> <es> <e id="e"></e> </es> <fs><f id="f"></f><f id="f"></f></fs> </aa> Here ds node will not give the same results as the other nodes, look at es node which is exactly the same with but with linefeeds. You will note in the Actual result section that ds declares having an object with property name '0' when it should be named 'd' This particularly fails when using things like get_object_vars(), it does not get the objects. Test script: --------------- $xml = simplexml_load_file("test.xml") print_r($xml); Expected result: ---------------- SimpleXMLElement Object ( [bs] => SimpleXMLElement Object ( [b] => b ) [cs] => SimpleXMLElement Object ( [c] => b ) [ds] => SimpleXMLElement Object ( [d] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => d ) ) ) [es] => SimpleXMLElement Object ( [e] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => e ) ) ) [fs] => SimpleXMLElement Object ( [f] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => f ) ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => f ) ) ) ) ) Actual result: -------------- SimpleXMLElement Object ( [bs] => SimpleXMLElement Object ( [b] => b ) [cs] => SimpleXMLElement Object ( [c] => b ) [ds] => SimpleXMLElement Object ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => d ) ) ) [es] => SimpleXMLElement Object ( [e] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => e ) ) ) [fs] => SimpleXMLElement Object ( [f] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => f ) ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => f ) ) ) ) )