preserveWhiteSpace = false; $dom->formatOutput = true; if ($dom->load($file)) { $xpath = new DomXpath($dom); $query = "//".$elemName."[@".$attrName."=\"".$attrValue."\"]"; $next = $xpath->query($query); foreach ($next as $item) { $item->parentNode->removeChild($item); } $dom->save($file); return true; } else { return false; } } // Formatte & indente le xml function indentXml($file) { $dom = new DOMDocument('1.0'); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; $dom->load($file); $dom->save($file); return true; } ?>