|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75245 simplexml_load_string() fails to parse an element filled only with spaces
Submitted: 2017-09-22 11:54 UTC Modified: -
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: lkppo at free dot fr Assigned:
Status: Closed Package: SimpleXML related
PHP Version: 7.0Git-2017-09-22 (Git) OS: Debian 9
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: lkppo at free dot fr
New email:
PHP Version: OS:


 [2017-09-22 11:54 UTC] lkppo at free dot fr
When I parses a validating XML with simplexml_load_string(), and this XML have an element filled only with spaces, the parser find an array of string instead of a string.

Test script:
$xmlpost = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<address1>   </address1>

$xml = simplexml_load_string($xmlpost);

echo '<pre>';


echo '</pre>';

Expected result:
object(SimpleXMLElement)#1 (1) {
  object(SimpleXMLElement)#2 (3) {
    string(7) "THIERRY"
    string(3) "   "
    object(SimpleXMLElement)#3 (0) {

Actual result:
object(SimpleXMLElement)#1 (1) {
  object(SimpleXMLElement)#2 (3) {
    string(7) "THIERRY"
    object(SimpleXMLElement)#3 (1) {
      string(3) "   "
    object(SimpleXMLElement)#4 (0) {


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-08-13 20:59 UTC] erik at coretech dot se
The following pull request has been associated:

Patch Name: Fix #75245: Don't set content of elements with only whitespaces
On GitHub:
 [2019-10-02 06:17 UTC]
Automatic comment on behalf of
Log: Fixed #75245 Don't set content of elements with only whitespaces
 [2019-10-02 06:17 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Nov 28 10:01:26 2023 UTC