Skip to content

Instantly share code, notes, and snippets.

@netdesign
Created November 27, 2011 16:55
Show Gist options
  • Select an option

  • Save netdesign/1397815 to your computer and use it in GitHub Desktop.

Select an option

Save netdesign/1397815 to your computer and use it in GitHub Desktop.
$data = "http://feeds.feedburner.com/metroq?format=xml";
$ch = curl_init($data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, false);
$result = curl_exec($ch);
curl_close($ch);
$xmlRawDoc = $result;
$xmlDoc = new DOMDocument();
$xmlDoc->loadXML($xmlRawDoc);
$xpath = new DOMXpath($xmlDoc);
$elm = $xpath->query("*/item");
foreach($elm as $el){
#echo $el->child()->nodeName;
$nodes = $el->childNodes;
$tPath = new DOMXpath($nodes);
$titles = $tPath->query("*/title");
foreach($titles as $title){
echo $title->nodeValue;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment