create and download xml file ??

Hi everybody,

I write a little code to create and download a XML file, everything works fine but I have some header text that I don’t want to have :
This is the content and in bold what I want to remove :

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”
http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd”>
<html DIR=‘LTR’>
<head>
<META http-equiv=“Content-Type” content=“text/html; charset=utf-8” />
<script type=“text/javascript” src="/scriptcase/prod/third/jquery/js/jquery.js"></script>
<script type=“text/javascript” src="/scriptcase/prod/third/jquery_plugin/malsup-blockui/jquery.blockUI.js"></script>
<script type=“text/javascript”>var sc_pathToTB = ‘/scriptcase/prod/third/jquery_plugin/thickbox/’;</script>
<script type=“text/javascript” src="/scriptcase/prod/third/jquery_plugin/thickbox/thickbox-compressed.js"></script>
<link rel=“stylesheet” href="/scriptcase/prod/third/jquery_plugin/thickbox/thickbox.css" type=“text/css” media=“screen” />
<link rel=“stylesheet” type=“text/css” href="…/_lib/css/LigthGray_Boldless/LigthGray_Boldless_grid.css" />
<link rel=“stylesheet” type=“text/css” href="…/_lib/css/LigthGray_Boldless/LigthGray_Boldless_gridLTR.css" />
</head>
<body class=“scGridPage”>
<table class=“scGridTabela” align=“center”><tr><td>
<?xml version=“1.0” encoding=“iso-8859-9” ?><?hash 986019720514e31de28bf8c5af674c36?><Stay … /></Stay>

This is the code :

$mhash=md5($xmlstring);

$xml=’<?xml version=“1.0” encoding=“iso-8859-9” ?>’;
$xml=$xml.’<?hash '.$mhash."?>";
$xml=$xml.$xmlstring;

$filename=“myfile.xml”;

file_put_contents($filename, $xml);

$msize=filesize($filename);

header(“Content-Type: application/xml”);
header(‘Content-Disposition: attachment; filename=’.$filename);
header(‘Expires: 0’);
header(‘Cache-Control: must-revalidate’);
header(‘Pragma: public’);
header('Content-Length: ’ . $msize);
readfile($filename);
exit;

Thanks
Nac

Ok now the question is where do you put the file, do you use a specific code for that?
The header… parts are indeed for the downloads, I guess you are doing this in a wrong event?

hello rr

The code is in a button and I use file_put_contents(), I suppose file is create in tmp directory.

Sorry, but I’m not sure I have understand your question ?

Thanks

You created a file apparently in the tmp dir so if you provide the link then you can have it downloaded. The file is somewhere, do you provide a download link? In what way do you show that there is a file to be downloaded?

Hello rr,

My problem is not to download the file, it’s work fine, my problem is that I have some header text that I don’t want to have in the downloaded file :
This header contents is in bold in my first thread

Thanks

Why you just dont sc_redir to your xml file? I think your problem is your readfile