I have used PHP with simplexml to parse RSS using standard elements before like <title> <pubDate> etc. But how would I parse something custom to the feed like <xCal:location> or <xCal:dtstart> that uses an xCal data element?
Something like $item->xCal:dtstart will error out. How would I collect this data element?
A sample of a feed like this: http://www.trumba.com/calendars/vd.rss?mixin=236393%2c236288
Try like this:
$feedUrl = 'http://www.trumba.com/calendars/vd.rss?mixin=236393%2c236288';
$rawFeed = file_get_contents($feedUrl);
$xml = new SimpleXmlElement($rawFeed);
$ns = $xml->getNamespaces(true);
//print_r($ns);
$xCal = $xml->channel->children($ns['xCal']);
echo ($xCal->version)."<br />";
foreach($xml->channel->item as $item)
{
//print_r($item);
$itemxTrumba=$item->children($ns['x-trumba']);
echo $itemxTrumba->masterid."<br />";
}
//print_r($xCal);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With