Bug #67572 [Ver->Dup]: SimpleXMLElement not parsing \n correctly (???)
| From: | cmb@php.net | Date: | Wed, 27 May 2015 17:52:02 +0000 |
| Subject: | Bug #67572 [Ver->Dup]: SimpleXMLElement not parsing \n correctly (???) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-192927@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67572&edit=1
ID: 67572
Updated by: cmb@php.net
Reported by: ondrej@php.net
Summary: SimpleXMLElement not parsing \n correctly (???)
-Status: Verified
+Status: Duplicate
Type: Bug
Package: SimpleXML related
Operating System: any
PHP Version: 5.6.0RC2
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
After further investigation it turned out that this is a duplicate
of bug #66084.
Previous Comments:
------------------------------------------------------------------------
[2015-05-26 19:28:24] cmb@php.net
Related To: Bug #61335
------------------------------------------------------------------------
[2015-05-26 19:06:17] cmb@php.net
Related To: Bug #66084
------------------------------------------------------------------------
[2015-05-26 12:16:43] cmb@php.net
Related To: Bug #62639
------------------------------------------------------------------------
[2014-08-08 16:10:04] csuffin at gracenote dot com
I have a work-around, of sorts. I hope someone is investigating this bug because it is pretty
awful.
I do not know how to solve the foreach() loop presented in ondrej's post, but if you're
accessing elements individually, it seems that leaving off the "[0]" subscript works.
Don't ask me why! See the test case below. If you run this test with the assignment from
"A" rather than "A[0]", it works.
<?php
function testfunc($str){
echo "Testing on \"$str\"\n";
$xml = new SimpleXMLElement($str);
$a = $xml->A[0];
//$a = $xml->A;
echo "$a";
if ($a) {
$result = 1;
} else {
$result = 0;
}
echo " $result \n\n";
return $result;
}
$r1 = testfunc ("<head><A>hello</A></head>");
$r2 = testfunc ("<head><A>first</A><A>hello</A>
</head>");
if ($r1 && !$r2)
echo " Test fails: white space makes 'A' element disappear! \n";
------------------------------------------------------------------------
[2014-07-08 04:46:03] yohgaki@php.net
http://3v4l.org/7vXEg
It seems it's broken since 5.4.0.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=67572
--
Edit this bug report at https://bugs.php.net/bug.php?id=67572&edit=1