How to get links from feed using php

in PHP Code / 3 Comments

Hello, following script is getting all urls and tiles from the feeds of the blog. If we want display the all urls and titles at your website then we get the information from below script:

function getlinks() {

$xml= "";

$xmlDoc = new DOMDocument();


//get elements from "<channel>"


$channel_title = $channel->getElementsByTagName('title')


$channel_link = $channel->getElementsByTagName('link')


$channel_desc = $channel->getElementsByTagName('description')



//get and output "<item>" elements


for ($i=0; $i<=7; $i++)








$result .= ("<p><a target="_blank" href='" . $item_link

. "'>" . $item_title . "</a>");

$result .= ("<br />");

$result .= ("</p>");


return $result;


We can see the live demo at  @

Thank you.

With more than 8 years experience in PHP and Founder of Anil Labs, a blog for PHP and related posts. contributed posts regarding CodeIgniter, CakePHP and Learn PHP online ...Contact : [email protected]

Discussion 3 Comments

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>