From: [EMAIL PROTECTED] Operating system: RedHat 7.2 PHP version: 4.1.1 PHP Bug Type: DOM XML related Bug description: conent of node node correct reading new DOM value after set_content of node
The following simplied script shows that when we update the value of a node, the DOM is updated as shown through the dump. When you try to read the content of the node however, it returns the origional value. If this is a bug, is there any known workaround to get the desired result? Also, we had to use the set_content as provided in the script because if a node already has a value and we try to call set_content directly on the node rather than on the the text element (value node), it appends the data to the node rather than overwriting the exisitng value. XPath is used in here as our real XML data is quite complex so needed to illustrate how we were finding the correct node. <? $xmltest = "<root_node><node1>ORG VALUE</node1></root_node>"; $mydoc = xmldoc($xmltest); echo "<pre>".$mydoc->dumpmem()."</pre><br>"; $ctx=$mydoc->xpath_new_context(); $query_xo = xpath_eval($ctx,"/root_node/node1"); $oNode = $query_xo->nodeset[0]; if (is_null($oNode)) { $root = $$mydoc->root(); $root->new_child("node1", "empty"); } else { $tNode = $oNode->first_child(); $tNode->set_content("VALUE1"); } echo "<pre>".$mydoc->dumpmem()."</pre><br>"; $ctx2=$mydoc->xpath_new_context(); $query_xo = xpath_eval($ctx2,"/root_node/node1"); $oNode = $query_xo->nodeset[0]; if (! is_null($oNode)) { $tNode = $oNode->first_child(); $strValue = $tNode->content; } echo "<br>GET VAL".$strValue."<br>"; echo "<pre>".$mydoc->dumpmem()."</pre>"; ?> -- Edit bug report at http://bugs.php.net/?id=15530&edit=1 -- Fixed in CVS: http://bugs.php.net/fix.php?id=15530&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=15530&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=15530&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=15530&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=15530&r=support Expected behavior: http://bugs.php.net/fix.php?id=15530&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=15530&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=15530&r=submittedtwice