Bug #67116 [NEW]: Inconsistent parsing of Nodes w/o linefeed
From: idefaye at gmail dot com
Operating system: Windows7 & IIS
PHP version: 5.4.27
Package: SimpleXML related
Bug Type: Bug
Bug description:Inconsistent parsing of Nodes w/o linefeed
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 bug report at https://bugs.php.net/bug.php?id=67116&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67116&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67116&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67116&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=67116&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=67116&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=67116&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=67116&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=67116&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=67116&r=support
Expected behavior: https://bugs.php.net/fix.php?id=67116&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=67116&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=67116&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=67116&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67116&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=67116&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=67116&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=67116&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=67116&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=67116&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=67116&r=mysqlcfg
Thread (5 messages)
- idefaye at gmail dot com