Jump to content

getting just one element


nickjonnes

Recommended Posts

hey all

i im trying to get the video link from this attom feed so far i have been sucessfull although i only want the first one not a whole list of themcan anyone help me

here is my code.

<?php
$xml = simplexml_load_file('http://video.news.com.au/feed.atom');
foreach( $xml->entry as $entry ) 
{
echo "Link - {$entry->link->attributes()->href}<br>";	
}
?>

Link to comment
https://forums.phpfreaks.com/topic/238475-getting-just-one-element/
Share on other sites

<?php
$xml = simplexml_load_file('http://video.news.com.au/feed.atom');
foreach( $xml->entry as $entry ) 
{
echo "Link - {$entry->link->attributes()->href}<br>";
break;
}
?>

 

or possibly just

<?php
$xml = simplexml_load_file('http://video.news.com.au/feed.atom');
echo "Link - {$xml->entry[0]->link->attributes()->href}<br>";
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.