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
 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 06 08:01:26 2024 UTC