Bug #67116 [Opn]: Inconsistent parsing of Nodes w/o linefeed
Edit report at https://bugs.php.net/bug.php?id=67116&edit=1
ID: 67116
User updated by: idefaye at gmail dot com
Reported by: idefaye at gmail dot com
Summary: Inconsistent parsing of Nodes w/o linefeed
Status: Open
Type: Bug
Package: SimpleXML related
Operating System: Windows7 & IIS
PHP Version: 5.4.27
Block user comment: N
Private report: N
New Comment:
Please note that in PHP5.3.9 it works properly, so it is a regression.
Previous Comments:
------------------------------------------------------------------------
[2014-04-23 13:52:53] idefaye at gmail dot com
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
)
)
)
)
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67116&edit=1
Thread (5 messages)