$html = file_get_contents($location); $dom = new DOMDocument; $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $el = $dom->getElementById($first); $el->parentNode->removeChild($el); $b = html_entity_decode($dom->saveHTML()); file_put_contents($location, $b); I use saveHTML () to save data to a file, but this function rebuilds the structure of the code. It was like this:
<div id="1"></div> <div id="2"></div> <div id="3"></div> <div id="4"></div> and after saving it became so:
<div id="1"> <div id="2"></div> <div id="4"></div> </div> should be like this after saving:
<div id="1"></div> <div id="2"></div> <div id="4"></div> How can this be fixed?
LIBXML_HTML_NOIMPLIED- RifmaMan