, function format_xml_file() , { , $xmlFile = filename.xml; , if( !file_exists($xmlFile) ) die(Missing file: . $xmlFile); , else , { , $dom = new DOMDocument(1.0); , $dom->preserveWhiteSpace = false; , $dom->formatOutput = true; , $dl = @$dom->load($xmlFile); // remove error control operator //(@) to print any error message , generated while loading. , if ( !$dl ) die(Error while parsing the document: . $xmlFile); , $dom->save($xmlFile); , } , } ,