RSS | Archive | Random | E-mail

About

Hi, I'm Christian Castelli, a 28 years old italian programmer located in Pisa (Italy). Here I post small snippets of code which can be useful in my work.

Links

Codepuzzling main site
Development site
ByteStrike italian blog
Follow me on Twitter

My Life Style

while(passion) {
  try {
    myLife.run();
  }catch(LifeExceptions) {  
    stronger++;
    continue;
   }
}

Following

6 August 09

[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;
   }
}

Comments (View)
Themed by Hunson. Originally by Josh