How can PHP be used to access and manipulate XML data from an external source like Imageshack API via cURL?

To access and manipulate XML data from an external source like Imageshack API via cURL in PHP, you can make a cURL request to the API endpoint, receive the XML response, and then parse and manipulate the XML data using PHP's SimpleXML functions.

<?php
// Initialize cURL session
$ch = curl_init();

// Set cURL options
curl_setopt($ch, CURLOPT_URL, 'https://api.imageshack.com/v2/images');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute cURL session and store the XML response
$response = curl_exec($ch);

// Close cURL session
curl_close($ch);

// Parse the XML response
$xml = simplexml_load_string($response);

// Access and manipulate the XML data as needed
foreach ($xml->images->image as $image) {
    echo "Image ID: " . $image->id . "<br>";
    echo "Image URL: " . $image->url . "<br>";
}
?>