|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26202 DomNode->set_content() method does not work propertly
Submitted: 2003-11-11 09:31 UTC Modified: 2003-11-11 13:15 UTC
From: michael_makarov at hotmail dot com Assigned:
Status: Wont fix Package: DOM XML related
PHP Version: 4.3.3 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2003-11-11 09:31 UTC] michael_makarov at hotmail dot com
set_content() method does not replace node content
now it`s look like
new content = old content + function argument

this is not:
Bug #19247 
Bug #23710 

Reproduce code:
$dom = domxml_open_mem("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Test>String1</Test>");
$node = $dom->document_element();
echo $dom->dump_mem();

Expected result:
<?xml version=\"1.0\" encoding=\"UTF-8\"?><Test>String2</Test>

Actual result:
<?xml version=\"1.0\" encoding=\"UTF-8\"?><Test>String1String2</Test>


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-11 09:41 UTC] michael_makarov at hotmail dot com
code below works fine, but i don`t understand why i need
get child node for replacing content?
$dom = domxml_open_mem("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Test>String1</Test>");
$node = $dom->document_element();
$cn  = $node->first_child();
echo $dom->dump_mem();
 [2003-11-11 13:10 UTC]
Just don't use set_content if you want reliable results. It's buggy as hell ;)

create_text_node()/append_child() is the better approach

 [2003-11-11 13:15 UTC]
shitty auto-form-completion... sorry again, will delete it in my browser...

-> changed summary line to original line
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Mar 02 17:01:28 2024 UTC