Bug #69169 [NEW]: Regression 5.2: simplexml_load_string parse wrongly when xml given in one row
From: nadavvin at gmail dot com
Operating system: windows,linux
PHP version: 5.6.6
Package: SimpleXML related
Bug Type: Bug
Bug description:Regression 5.2: simplexml_load_string parse wrongly when xml given in one row
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
)
)
)
)
)
--
Edit bug report at https://bugs.php.net/bug.php?id=69169&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69169&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69169&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69169&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69169&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69169&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69169&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69169&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69169&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69169&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69169&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69169&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69169&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69169&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69169&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69169&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69169&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69169&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69169&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69169&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69169&r=mysqlcfg
Thread (4 messages)
- nadavvin at gmail dot com