#37669 [NEW]: Setting a node's value from array returned by xpath does not work
From: justinpatrin@php.net
Operating system: Linux (Gentoo, RHEL)
PHP version: 5.1.4
PHP Bug Type: SimpleXML related
Bug description: Setting a node's value from array returned by xpath does not work
Description:
------------
When trying to set the value (inside text) of a node from an array
returned from an xpath call nothing happens. Setting an attribute works
fine, however. Setting via normal -> access works as expected.
Reproduce code:
---------------
$xml = simplexml_load_string('<root><node/><node2/></root>');
if (is_array($nodes = $xml->xpath('node'))
&& sizeof($nodes) > 0
&& is_object($nodes[0])) {
$nodes[0]['value'] = 'Hello';
$nodes[0] = 'World';
}
$xml->node2 = 'World';
header('Content-Type: text/xml');
echo $xml->asXML();
Expected result:
----------------
<root><node
value="Hello">World</node><node2>World</node2></root>
Actual result:
--------------
<root><node value="Hello"/><node2>World</node2></root>
--
Edit bug report at http://bugs.php.net/?id=37669&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37669&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37669&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37669&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=37669&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=37669&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=37669&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=37669&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=37669&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=37669&r=support
Expected behavior: http://bugs.php.net/fix.php?id=37669&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=37669&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=37669&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=37669&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37669&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=37669&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=37669&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=37669&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=37669&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=37669&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=37669&r=mysqlcfg
Thread (4 messages)
- justinpatrin@php.net