Jump to:

22977 Posts in 11806 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Parse values and attributes from RSS feed

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 537 Views
  • Imploosio
    Avatar
    Community Member
    5 Posts

    Parse values and attributes from RSS feed Link to this post

    Hello you'se,

    I'm using RestfulService to parse in an external RSS feed, just a really simple list of news items with header and a link. On the XML I'm parsing, I have mix of values and attributes. I can get the headers and everything else I need with this snippet of code from RestfulService reference tutorial:

    function ParseFeed($url){
    $rss = new RestfulService($url);
    $conn = $rss->request()->getBody();
    $result = $rss->getValues($conn, "entry");
    $output = '';
    foreach ($result as $key => $value) {
    $output .= '<li><a href="'.$value->link.'">'.$value->title.'</a>';
    }
    return $output;
    }

    This returns the title but leaves the URL blank -- because it is href attribute on the 'link' node instead of value data. How should I go about getting the href attribute for my links? I suspect I need to use some combination of getValues and getAttributes, but I don't really have any clue how. Any help is highly appreciated!

    537 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.