SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Nov 2012
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem reading Link in Atom RSS feed

    [quote name='shahab.fm' timestamp='1353765756' post='1394745']
    Hi,

    I am trying to read the atom atom rss standard with the following code, but I do not manage to read the LINK & CONTENT. Could you please help me ? I have posted my php code here and I also attached a sample of the XML code i am reading with its source link under here. Thank in advance for your help.

    Code:
    <?php
    function getFeed($feed_url)
    {
    $content = file_get_contents($feed_url);
    $x = new SimpleXmlElement($content);
    echo "<ul>";
    foreach($x->entry as $entry)
    {
    //WORKS
    echo $entry->title;
    echo $entry->author->name;
    //DOESNT WORK
    echo $entry->content;
    echo $entry->link;
    }
    echo "</ul>";
    }
    ?>
    A sample of RSS code I am reading :

    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <feed xmlns="http://www.w3.org/2005/Atom">
    <title>FINN jobb - Alle stillinger</title>
    <link rel="alternate" href="http://www.finn.no/finn/job/fulltime/result/" title="FINN jobb - Alle stillinger" />
    <rights>Copyright 2010</rights>
    <logo>http://cache.finn.no/img/logofinn.gif</logo>
    <entry>
    <title>Lyst å jobbe med IT support?</title>
    <link rel="alternate" href="http://www.finn.no/finn/object?finnkode=38539103" title="Annonse" />
    <author>
    <name>People4you It Bemanning AS</name>
    </author>
    <published>2012-11-24T00:07:00Z</published>
    <content type="html">&lt;div&gt;&lt;div style='float:left;'&gt;Sted: Oslo&lt;br/&gt;Firma: IT People4you&lt;br/&gt;Tittel: Support / brukerstøtte&lt;br/&gt;Kategori: IT / Telekommunikasjon / Internett, IT / Telekommunikasjon / Internett&lt;br/&gt;&lt;/div&gt;&lt;/div&gt;</content>
    </entry>
    Source
    [/quote]

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,058
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    From what I remember about SimpleXml to get to the link href you have to use attributes() like so
    PHP Code:
    $entry->link->attributes()->href 
    http://www.php.net/manual/en/simplex...attributes.php

    From what I can tell content should be reading the value of the XML node content which is encoded html. So I'm not sure why you are not getting that back...
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •