php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15949 replace_node feature
Submitted: 2002-03-08 02:59 UTC Modified: 2002-04-15 11:41 UTC
From: bigredlinux at yahoo dot com Assigned:
Status: Closed Package: DOM XML related
PHP Version: 4.1.2 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bigredlinux at yahoo dot com
New email:
PHP Version: OS:

 

 [2002-03-08 02:59 UTC] bigredlinux at yahoo dot com
I realize that for replace_node, the W3C recommendation suggests that you should return the node that was removed.  However, this presents a problem when you are actually trying to write code with the xml functions.  If you create a new node (or import it from another document, or even clone it) and then you do a replace node somewhere, removing the previous node and putting in your new node, there is no way to access the node you just put in.  For all intents and purposes, you have lost your place in the document.  I don't think the function should change per say, but rather this following distinction.

1. Create a new node and return it to a variable $foo
2. Select a node that will be replaced $bar
3. Replace $bar with $foo using $bar->replace_node($foo)
4. Now, $foo should be a reference to the node in its new location.  This argument is based on the recommendation sentence which states "if the newChild is already in the tree, it is first removed".  Hence, it would be impossible for the reference $foo to exist anywhere else then in its new location.

Thoughts?

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-15 11:41 UTC] steinm@php.net
This bug has been fixed in CVS.

Consider remove_child() instead of remove_node() since
remove_child() is part of DOM. Anyway, even remove_node()
returns the old node now.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 07 01:01:30 2024 UTC