Hi guys, I'm using my usual ass backwards coding again to write data into an XML file. I'm attempting to use
<?
$filename = "dirTree.xml";
$handle = fopen($filename, 'w');
//
$xmlDeclaration = ("<?xml>\n");
$firstNode = (" <dir>\n");
fputs($handle, $xmlDeclaration);
fputs($handle, $firstNode);
searchfolder ("./");
//
function searchfolder ($folder) {
$childNodes = ("");
//go through all the contents of the folder
$dir = opendir ($folder);
while (($file = readdir ($dir)) !== FALSE) {
if ($file != "." && $file != "..") {
$childNodes = (" <file>$file</file>\n");
fputs($handle, $childNodes);
}
}
}
//
$closeDoc = (" </dir>");
fputs($handle, $closeDoc);
fclose($handle);
?>
but the while loop in the middle is failing and not writing the data. Basically the $childNodes variable consists of all the files in a directory, but I can't seem to be able to fit them between the surrounding XML tags I'm writing at the top and end of the code. Any ideas? I've tried pushing each $file var into an array and the looping that, but I keep getting erros. It's been one of those days you see...
Cheers