php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37386 autocreating element doesn't assign value to first node
Submitted: 2006-05-09 19:44 UTC Modified: 2007-03-26 20:18 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: m dot kurzyna at crystalpoint dot pl Assigned: helly (profile)
Status: Closed Package: SimpleXML related
PHP Version: 5.1.4 OS: Linux
Private report: No CVE-ID: None
 [2006-05-09 19:44 UTC] m dot kurzyna at crystalpoint dot pl
Description:
------------
If autocreating new nodes by id ($obj->node[0] = '') 
SimpleXML doesn't assign value to first node. Creating 
first node w/o using id works fine.

Reproduce code:
---------------
<?php

  $sx1 = new SimpleXMLElement("<root />");

  $sx1->node[0] = 'node1';
  $sx1->node[1] = 'node2';

?>

Expected result:
----------------
object(SimpleXMLElement)[1]
  public 'node' => 
    array
      0 => 'node1' (length=5)
      1 => 'node2' (length=5)

Actual result:
--------------
object(SimpleXMLElement)[1]
  public 'node' => 
    array
      0 => 
        object(SimpleXMLElement)[6]
      1 => 'node2' (length=5)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-06 18:40 UTC] archilles_sw at users dot sourceforge dot net
The same here as I went deeper into simplexml...

PHP 5.2.0 Linux

SimpleXMLElement Object
(
    [node] => Array
        (
            [0] => SimpleXMLElement Object
                (
                )

            [1] => node2
        )

)
 [2007-03-26 20:18 UTC] rrichards@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 09:01:30 2024 UTC