busillis Posted June 12, 2008 Share Posted June 12, 2008 I'm using xpath to get the title and link node from an RSS feed, but I want the script to output like this: <a href="$link">$title</a> I'm trying to make two seperate splits, using xpath and &&, but this keeps failing... ??? Quote Link to comment https://forums.phpfreaks.com/topic/109908-solved-foreach-ampamp/ Share on other sites More sharing options...
kenrbnsn Posted June 12, 2008 Share Posted June 12, 2008 Please post the code you're using. Ken Quote Link to comment https://forums.phpfreaks.com/topic/109908-solved-foreach-ampamp/#findComment-563953 Share on other sites More sharing options...
preet Posted June 12, 2008 Share Posted June 12, 2008 I would like to see the code, but what I understand is you want to collect links from RSS feed.........better u use xml parser class...for parsing xml feed cheers Quote Link to comment https://forums.phpfreaks.com/topic/109908-solved-foreach-ampamp/#findComment-563956 Share on other sites More sharing options...
busillis Posted June 12, 2008 Author Share Posted June 12, 2008 Thanks <?php $html = file_get_contents("http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml"); $xml = new SimpleXMLElement($html); $count = 0; foreach ($xml->xpath('//item/title|//item/link') as $node) { echo $node, '<br>'; if ($count && $count % 2) { echo '<hr>'; } ++$count; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/109908-solved-foreach-ampamp/#findComment-563962 Share on other sites More sharing options...
busillis Posted June 12, 2008 Author Share Posted June 12, 2008 Had an idea. Does anyone know how as $node is stored? i.e. using a character as seperation? If so, I could explode this? Quote Link to comment https://forums.phpfreaks.com/topic/109908-solved-foreach-ampamp/#findComment-563977 Share on other sites More sharing options...
busillis Posted June 12, 2008 Author Share Posted June 12, 2008 I've worked it out! Quote Link to comment https://forums.phpfreaks.com/topic/109908-solved-foreach-ampamp/#findComment-564047 Share on other sites More sharing options...
ober Posted June 12, 2008 Share Posted June 12, 2008 Mind posting the solution for anyone else that finds this thread? And please mark the thread as solved. Quote Link to comment https://forums.phpfreaks.com/topic/109908-solved-foreach-ampamp/#findComment-564052 Share on other sites More sharing options...
busillis Posted June 20, 2008 Author Share Posted June 20, 2008 Here's the solution: foreach ($xml->xpath('//item') as $node) { echo $node->link echo $node->description Quote Link to comment https://forums.phpfreaks.com/topic/109908-solved-foreach-ampamp/#findComment-570099 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.