php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81279 Inconsistant parsing with simplexml_load_string function
Submitted: 2021-07-21 15:39 UTC Modified: 2021-07-22 08:04 UTC
From: a dot gargasas1238 at gmail dot com Assigned:
Status: Open Package: SimpleXML related
PHP Version: Irrelevant OS: irrelavant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
47 + 34 = ?
Subscribe to this entry?

 
 [2021-07-21 15:39 UTC] a dot gargasas1238 at gmail dot com
Description:
------------
bug appears in versions:
7.0.5 and later

description:
Parsing XML string returns inconsistent values. When parsing single XML element with new lines (unix (\n) or win(\r\n)) resulting element will be array. When new line tags are removed element turns into object value.

Test script:
---------------
https://pastebin.com/hfv4bMZ8

Expected result:
----------------
Consistent result of parsing element as object value, or as array

Actual result:
--------------
Inconsistent result: mix of object value and array

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-07-22 08:04 UTC] cmb@php.net
Confirmed: <https://3v4l.org/GGGnX>.

The problem is that the whitespaces are parsed as text nodes, and
SimpleXML has known issues with mixed content, especially
regarding debug output (such as var_dump()).
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Oct 04 03:05:53 2022 UTC