note 128605 added to class.simplexmlelement

From: Date: Mon, 12 Jun 2023 03:28:02 +0000
Subject: note 128605 added to class.simplexmlelement
Groups: php.notes 
Request: Send a blank email to php-notes+get-220563@lists.php.net to get a copy of this message
You can remove SimpleXMLElement nodes using php's unset() language construct. <?php $xml = <<<'EOT' <users> <user> <name>orange</name> <sex>male</sex> <homepage>wuxiancheng.cn</homepage> </user> <user> <name>tangerine</name> <sex>male</sex> <homepage>51-n.com</homepage> </user> </users> EOT; $sxe = new SimpleXMLElement($xml); // This will remove the first user node unset($sxe->user[0]); // This will remove all user nodes unset($sxe->user); echo $sxe->asXML(); ?> ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.13.130 (proxied: 2409:8a62:2c1b:13c0:4f:c404:96d4:2153) ---- Manual Page -- https://php.net/manual/en/class.simplexmlelement.php Edit -- https://main.php.net/note/edit/128605 Del: integrated -- https://main.php.net/note/delete/128605/integrated Del: useless -- https://main.php.net/note/delete/128605/useless Del: bad code -- https://main.php.net/note/delete/128605/bad+code Del: spam -- https://main.php.net/note/delete/128605/spam Del: non-english -- https://main.php.net/note/delete/128605/non-english Del: in docs -- https://main.php.net/note/delete/128605/in+docs Del: other reasons-- https://main.php.net/note/delete/128605 Reject -- https://main.php.net/note/reject/128605 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#220563) next »