How can XML data be extracted from a URL in PHP?
To extract XML data from a URL in PHP, you can use the simplexml_load_file() function, which loads an XML file and returns an object representing the XML document. You just need to pass the URL of the XML file as a parameter to this function.
$url = 'http://example.com/data.xml';
$xml = simplexml_load_file($url);
// Now you can access the XML data using the $xml object
foreach ($xml->children() as $child) {
echo $child->getName() . ": " . $child . "<br>";
}