php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: michael_makarov at hotmail dot com
New email:
PHP Version: OS:

 

 [2003-11-11 09:31 UTC] michael_makarov at hotmail dot com
Description:
------------
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();
$node->set_content("String2");
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>

Patches

Pull Requests

History

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();
$cn->set_content("String2");
echo $dom->dump_mem();
?>
 [2003-11-11 13:10 UTC] chregu@php.net
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

chregu
 [2003-11-11 13:15 UTC] chregu@php.net
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 Dec 21 12:01:31 2024 UTC