Forum Moderators: coopster
So I've got a php script that dynamically creates a list of files and in xml format.
Now, I'd like that xml data to be outputted to an actual xml file when I run the script. I keep trying, but it keeps messing up along the way.
This is the code I've been trying to do the writing. the header and $template line is what generates the xml (taken from the script above it, didn't see the need to add the whole thing here). The $fp part under is the code I've been using to attempt write the file (text.xml, chmodded to 777).
header("Content-type: text/xml");
$template->pparse('body');
$fp = fopen("test.xml", "w");
fwrite($fp, $template);
fclose($fp);
Some variations of that code I've been able to get write about 5 characters but then it cuts out.
Any ideas? I'm using php 4.3.11.
I assume you have output the $template var to be sure there is something in there
it looks like you have already checked permissions
is this a file that exists always and you just keep overwriting the data?
you could try using the optional third param for fwrite [length] and specify a ridiculously large int
might work
I checked the output of $template, it looks perfect. Yeah, I've got the xml file chmodded correctly too.
The file is a blank xml file that I'd like to be over-written every time I run the script, with the output generated from $template.
I'll give the [length] a shot and let you know!