Forum Moderators: coopster

Message Too Old, No Replies

filenames into array into xml

dynamic xml generation

         

kristtee

5:28 am on Oct 30, 2008 (gmt 0)

10+ Year Member



Hi
I am new to php. Hope this is possible using php. Following is step by step functionals the script should do

1. accept the input directory
2. read the directory/subdirectory
3. take all jpgs and mp3s into an array
4. generate a simple xml file adding the array values for a specific xml tag
is it possible to do it in php? Where do i begin? Is there some tutorials for this sort?
Appreciate your time and help
Thank you
Krs

dreamcatcher

8:29 am on Oct 30, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<?php
$files = array();
$dir = opendir [uk2.php.net]('path to /directory/');
while ($read = readdir [uk2.php.net]($dir)) {
if ($read!='.' && $read!='..') {
$files[] = $read;
}
}
closedir [uk2.php.net]($dir);

?>

<?php $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; ?>
<?php
// Output as xml...
if (!empty($files)) {
foreach [uk2.php.net] ($files AS $ext) {
$xml .= '<tag>'.$ext.'</tag>';
}
}

header('Content-Type: text/xml');
echo trim($xml);
?>

Something like that might get you started. And welcome to WebmasterWorld kristtee. :)

dc