我有这个代码
$doc = new DOMDocument;
$doc->load('Clans/' . $_POST['s']);
$thedocument = $doc->documentElement;
//this gives you a list of the messages
$list = $thedocument->getElementsByTagName('member');
foreach($_POST['delete_unit'] as $unit_id){
$nodeToRemove = null;
foreach ($list as $domElement){
$attrValue = $domElement->getAttribute('id');
if ($attrValue == $unit_id) {
$nodeToRemove = $domElement; //will only remember last one- but this is just an example :)
}
}
}
//Now remove it.
if ($nodeToRemove != null)
$thedocument->removeChild($nodeToRemove);
$doc->saveXML('Clans/' . $_POST['s']);
POST['delete_unit'] 是 ids 数组为什么这不起作用或有更好的方法来做到这一点
错误代码 PHP Catchable 致命错误:传递给 DOMDocument::saveXML() 的参数 1 必须是 DOMNode 的实例,字符串在