php list of filenames with special characters output to xml

yaya

New Member
Alert: I am extremely inexperienced with php.I'm trying to read the names of a list of files on the server and create an XML file with these. Some of these have foreign language characters and this causes problems during XML creation.After searching around I realise I probably need to use \[code\]htmlspecialchars\[/code\] or \[code\]rawurlencode\[/code\], but I have been unable to get these working.The code below was constructed from code I found online. There is no particular reason for doing anything this way other than not knowing any better.\[code\]$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(realpath($_SERVER['DOCUMENT_ROOT'])), RecursiveIteratorIterator::SELF_FIRST);header("Content-Type: text/xml;");echo '<?xml version="1.0" encoding="UTF-8"?><list>';foreach($objects as $name){ echo '<file><loc>'.$name.fileName.'</loc><lastmod>'.date('Y-m-d',filemtime($name)).'</lastmod></file>';}echo '</list>'; \[/code\]Clarification: It's not that \[code\]rawurlencode\[/code\] fails, it's just that I don't know how to save it in the XML file decoded\[code\]<file> <loc> http://%2Fhome%2Fusers%2Fjdfvnftp%2Fjdfv.nl%2Fptp%2Ftorrents%2FBuck.2011.DVD.XviD.AVI.106682.torrent.importedfileName </loc> <lastmod>2012-05-29</lastmod></file>\[/code\]
 
Back
Top