I've got two folders images and big images with photos.
I want to generate an XML file with two attributes like this :
<images>
<image source="images/image1" lightbox="bigimages/image1" />
.....
</images>
I have something like this :
<?php
// enter the path to the folder
$path = "images/";
// opendir
$dir_handle = @opendir($path) or die("Unable to open $path");
// table photos
$filetypes = array("jpg", "png");
// forming xml
$doc = new DomDocument('1.0');
$doc->formatOutput = true;
// forming images
$root = $doc->createElement('images');
$root = $doc->appendChild($root);
while ($file = readdir($dir_handle)) {
$file = rawurlencode($file);
$split = explode(".", $file);
$ext = strtolower($split[count($split)-1]);
if (in_array($ext, $filetypes)) {
// additional image
$item = $doc->createElement("image");
$item = $root->appendChild($item);
$file = $path.$file;
// adding an attribute source
$item->setAttribute('source', $file);
}
}
// closure
closedir($dir_handle);
// Save to XML
$doc->save("plik.xml");
echo "plik xml wygenerowany poprawnie!!!";
?>
And now the question is how to add second attribute with path to images from "bigimages" directory.