]+>)(<[^>]+>)(<[^>]+>)/', "$1\n$2\n$3", $xml); $xml = preg_replace('/(<[^>]+>)(<[^>]+>)/', "$1\n$2", $xml); // Return if is marked to return. if ($return) { return $xml; } // Download if marked to download. if ($filename !== false) { // Cookie for download control. setDownloadCookieToken(); header('Content-Type: application/xml; charset=UTF-8'); header('Content-Disposition: attachment; filename="'.$filename.'.xml"'); } // Clean the output buffer. ob_clean(); echo $xml; }