I’m trying to figure out how to remove a child with a specific attribute selected (filename). I have PHP displaying an XML file on a page that loads images. If someone where to click on any image or hit the delete button -
<a href=""><img src="' . $child['src'] . '" alt="gallery image" />Delete me</a>
it would know where to find in the XML file and delete it.
Here what loads and displays my XML file:
<?php
$xml = simplexml_load_file('myPhotos.xml');
//echo $xml->getName() . "<br />";
foreach ($xml->children() as $child)
{
echo '<img src="' . $child['src'] . '" alt="gallery image" />';
}
?>
Here is my XML structure:
<slideshow>
<image src="myPhotosResized/image1.jpg" desc="This is the 1st image!" />
<image src="myPhotosResized/image2.jpg" desc="This is the 2nd image!" />
<image src="myPhotosResized/image3.jpg" desc="This is the 3rd image!" />
<image src="myPhotosResized/image4.jpg" desc="This is the 4th image!" />
</slideshow>