Feeds returning <guid> for entry.link instead of <link>

38 views
Skip to first unread message

Christian McDonald

unread,
Jul 28, 2014, 4:10:50 PM7/28/14
to google-ajax...@googlegroups.com
Hello all,

I'm using Google Feeds API to pull create a list of headlines from an RSS feed.

I'm using the "entry.link" attribute to get a URL for the href of an item in the list. According to documentation this should return the <link> attribute in the RSS feed, but it is instead returning the <guid>, which is a different value (and not what I want).

An example feed, which validates per W3:


Here is an example of where this is used;

The "Recent stories from the Austin Homicide Project" list shows the returns. Note the href is something like:


which is the value for <guid>

instead of:


which is the value for <link>

This is the script:
        <script type="text/javascript" src="https://www.google.com/jsapi"></script>
        <script type="text/javascript">
            google.load("feeds", "1");
            function initialize() {
              var feed = new google.feeds.Feed(RSS_feed);
            feed.setNumEntries(20);
              feed.load(function(result) {
                if (!result.error) {
                  var container = document.getElementById("feed");
                  for (var i = 0; i < result.feed.entries.length; i++) {
              var entry = result.feed.entries[i];
              var li = document.createElement("li");
              li.innerHTML = '<a href="' + entry.link + '">' + entry.title + '</a>';
              container.appendChild(li);
                  }
                }
              });
            }
            google.setOnLoadCallback(initialize);
        
        document.write("<h4>Recent stories from the Austin Homicide Project<\/h4>");
        document.write("<div id=\"medleycontent\">");
        document.write("  <ul id=\"feed\">");
        document.write("  <\/ul>");
        document.write("<\/div>");
        </script>

Any ideas how I can get the <link> instead of <guid>?

Matti Nescio

unread,
Jul 30, 2014, 7:47:46 PM7/30/14
to google-ajax...@googlegroups.com
On Monday, 28 July 2014 23:10:50 UTC+3, Christian McDonald wrote:
Any ideas how I can get the <link> instead of <guid>?

Any difference with a feed that specifies ispermalink=false for the <guid> ? 
 

Jeremy Geerdes

unread,
Jul 30, 2014, 7:58:53 PM7/30/14
to google-ajax...@googlegroups.com
I don't know why the service is doing this, but as long as it is, one possible workaround would be to get the feed in MIXED format and then parse through the XML for each entry for the information you desire. If you're using the JS library, the XML will be parsed for you, and you'll be able to use DOM methods on it.

jg




--
--
You received this message because you are subscribed to the Google
Groups "Google AJAX APIs" group.
To post to this group, send email to
google-ajax...@googlegroups.com
To unsubscribe from this group, send email to
google-ajax-searc...@googlegroups.com
To view this message on the web, visit
https://groups.google.com/d/msgid/google-ajax-search-api/7e4c8b3f-86ee-4854-8bb8-00cc1ca927c7%40googlegroups.com

For more options, visit this group at
http://groups.google.com/group/google-ajax-search-api?hl=en?hl=en

---
You received this message because you are subscribed to the Google Groups "Google AJAX APIs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-ajax-searc...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Jeremy R. Geerdes
Generally Cool Guy
Des Moines, IA

If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan Church!
Reply all
Reply to author
Forward
0 new messages