XML from a file list?
- Started
- Last post
- 4 Responses
- slappy
Anyone have a php script that will create an xml file from a file list?
I'm too lazy to keep my xml files updated everytime I drop an image into a folder.
*crosses fingers
- toul0
no-one? i know...we have to use google.
- unfittoprint0
use opendir on your target folder contents
http://pt.php.net/opendiruse readdir in a while loop to retrieve your folder contents
http://pt.php.net/readdir
while (false !== ($file = readdir($handle)))use eregi function to filter your content and $file != "." && $file != ".." to avoid folders
http://pt.php.net/eregiin each loop add your node to a string variable.
echo it at the end [encode your var using utf8_encode just as a precaution].
note: before the loop write your xml header [firefox testing]
good luck.
- Epictive0
It's not tuff to make one real quick. In the comments here http://us2.php.net/manual/en/fun… there are some good examples of reading directories, just have it echo out xml tags instead of HTML or whatever.
- Epictive0
Unfit beat me to it, but there are examples using the method he describes in the comments on the link I posted. Good luck.