<?php
$str = '<?xml version="1.0" encoding="utf-8"?>
<infos>
<info time="1249731817" count="0" detail="Ke ke ke" uid="253" path="/phungvanhuy.net/earn-money.txt"/>
</infos>
';
$doc = new SimpleXMLElement($str);
$doc = simplexml_load_string($str);
/*
foreach ($doc as $info) {
if ($info["path"] = '/phungvanhuy.net/earn-money.txt') {
$dom=dom_import_simplexml($info);
$dom->parentNode->removeChild($dom);
break;
}
}
*/
$infos = $doc->xpath("//info[@path='/phungvanhuy.net/earn-money.txt']");
if (count($infos) >= 1) {
$dom=dom_import_simplexml($infos[0]);
$dom->parentNode->removeChild($dom);
}
echo $doc->asXML();
?>
Title:
simplexml - remove element - no unset
Description:
<?php $str = '<?xml version="1.0" encoding="utf-8"?> <infos> <info time="1249731817...
...
Rating:
4