"); $xml->addAttribute("version", "1"); $urlToScriptUrl = $url; // Výpis souborů: foreach(glob("*.[dD][dD][iI]") as $file) { $version = filemtime($file); $xmlFile = $xml->addChild("File"); $xmlFile->addAttribute("url", $urlToScriptUrl . $file); $xmlFile->addAttribute("version", $version); addOptionalAttributes($xmlFile, $file); } return $xml->asXML(); } function addOptionalAttributes($xmlFile, $file) { // V této funkci můžeme jednoduše definovat atributy "name" a "note" pro určité soubory. // Ukázkové soubory je možné odstranit. // K souboru "my-file-1.ddi" přidá atributy "name=My File 1 Name" a "note=My File 1 Note". setFileNameAndNote($xmlFile, $file, "my-file-1.ddi", "My File 1 Name", "My File 1 Note"); // K souboru "my-file-2.ddi" přidá atributy "name=My File 2 Name". setFileNameAndNote($xmlFile, $file, "my-file-2.ddi", "My File 2 Name", ""); // K souboru "my-file-3.ddi" přidá atributy "note=My File 3 Note". setFileNameAndNote($xmlFile, $file, "my-file-3.ddi", "", "My File 3 Note"); } function setFileNameAndNote($xmlFile, $file, $f, $name, $note) { if (isEqual($f, $file)) { // Attributes "name" and "note" are optional. if (isNullOrEmptyString($name) == false) $xmlFile->addAttribute("name", $name); if (isNullOrEmptyString($note) == false) $xmlFile->addAttribute("note", $note); } } function isEqual($str1, $str2) { return strcasecmp($str1, $str2) == 0; } function isNullOrEmptyString($str) { return ($str === null || trim($str) === ''); } Header("Content-type: text/xml"); $url = getURL(); $xml = createXml($url); print($xml); ?>