[PHP] How to retrive urls in Google sitemap into an array
This code makes use of SimpleXMLElement class.
function sitemap2array($http_url) {
$sitemap = simplexml_load_file($http_url);
if($sitemap !== FALSE)
{
$arr = array();
foreach($sitemap->children() as $b)
if($b->getName() == "url")
$arr[]= (string)$b->{'loc'};
return $arr;
}
}