One of the basic usage of simpleXML, which I find quite useful is to grab the links of latest post the of RSS enabled site.
Here’s How:
I will be using the links to my site…
<?php
$feed = 'http://gumz-ex-press.com/feed/';//You can replace the website
$contents = file_get_contents($feed);
$xml = new SimpleXMLElement($contents);
foreach($xml->channel->item as $feeditem){
?>
<a href="<?php echo $feeditem->link;?>"><?php echo $feeditem->title; ?></a><br />
<?php
}
?>
You can include the description as you like by adding $feeditem->description after break.
<?php
$feed = 'http://gumz-ex-press.com/feed/';//You can replace the site
$contents = file_get_contents($feed);
$xml = new SimpleXMLElement($contents);
foreach($xml->channel->item as $feeditem){
?>
<a href="<?php echo $feeditem->link;?>"><?php echo $feeditem->title; ?></a><br />
<?php echo $feeditem->description;//add description
}
?>