Bug #69169 [Ver]: Regression 5.2: simplexml_load_string parse wrongly when xml given in one row
From: nadavvin at gmail dot com Date: Wed, 04 Mar 2015 08:24:15 +0000 Subject: Bug #69169 [Ver]: Regression 5.2: simplexml_load_string parse wrongly when xml given in one row References: 1 Groups: php.bugs Request: Send a blank email to php-bugs+get-191125@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69169&edit=1
ID: 69169
User updated by: nadavvin at gmail dot com
Reported by: nadavvin at gmail dot com
Summary: Regression 5.2: simplexml_load_string parse wrongly
when xml given in one row
Status: Verified
Type: Bug
Package: SimpleXML related
Operating System: windows,linux
PHP Version: 5.6.6
Block user comment: N
Private report: N
New Comment:
It's happen also in var_dump, json_encode:
var_dump($simple_xml);
echo json_encode($simple_xml);
http://3v4l.org/RUnot
Previous Comments:
------------------------------------------------------------------------
[2015-03-03 19:46:01] requinix@php.net
http://3v4l.org/VAjaa
May just be the print_r() output since ->row[0]->item works fine.
http://3v4l.org/UcBUO
------------------------------------------------------------------------
[2015-03-03 10:36:16] nadavvin at gmail dot com
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 this bug report at https://bugs.php.net/bug.php?id=69169&edit=1
Thread (4 messages)
- Bug #69169 [Opn->Ver]: Regression 5.2: simplexml_load_string parse wrongly when xml given in one row
- Bug #69169 [Ver]: Regression 5.2: simplexml_load_string parse wrongly when xml given in one row
- Bug #69169 [Ver->Dup]: Regression 5.2: simplexml_load_string parse wrongly when xml given in one row
| « previous | php.bugs (#191125) | next » |
|---|