php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42437 Results from xpath() cannot be deleted
Submitted: 2007-08-27 08:23 UTC Modified: 2007-08-27 10:29 UTC
From: guenther dot stadler at gmx dot net Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: 5.2.3 OS:
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: guenther dot stadler at gmx dot net
New email:
PHP Version: OS:

 

 [2007-08-27 08:23 UTC] guenther dot stadler at gmx dot net
Description:
------------
Elements of the array returned by xpath() cannot be deleted.
I can change those elements, but deleting is impossible.

How can I delete a node returned by xpath()? Is there a way to find out where the node I found is within the whole xml tree?

Thanks, G?nther.

Reproduce code:
---------------
<?php
$xmlstr = <<<XML
<?xml version='1.0' standalone='yes'?>
<root>
 <movie>Movie One</movie>
 <movie>Movie Two</movie>
</root>
XML;

$xml = new SimpleXMLElement($xmlstr);

$movs = $xml->xpath('//movie');

// Trying to delete the reference returned by xpath
unset($movs[0]);

// $movs[0] = NULL; doesn't work either

// No changes
echo $xml->asXML();

?>


Expected result:
----------------
<?xml version="1.0" standalone="yes"?>
<root>
 <movie>Movie Two</movie>
</root>

Actual result:
--------------
<?xml version="1.0" standalone="yes"?>
<root>
 <movie>Movie One</movie>
 <movie>Movie Two</movie>
</root>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-27 10:29 UTC] jani@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Nov 29 15:05:53 2022 UTC