I've currently got a very simple page taking info from an RSS feed
(Reuters), using the pretty much stock code from the api playground.
What i would like to do is loop through the feed results and put each
item into it's own layer, with the layer style set to float:left, so i
end up with something like this...
News feed item 1 News feed item 2 News feed item 3 News feed item 4
etc
I understand i'm creating the DIV element in javascript; how do i ask
the code to put the results into separate layers appended as above? Do
i need to create separate result containers for each news feed item?
Ideally i guess i want to be dynamically creating layers for each news
item and then styling them using CSS...? Thanks!
<script type="text/javascript">
/*
* How to see historical entries in a feed. Usually a feed only
returns x number
* of results, and you want more. Since the Google Feeds API
caches feeds, you can
* dig into the history of entries that it has cached. This,
paired with setNumEntries,
* allows you to get more entries than normally possible.
*/
google.load("feeds", "1");
// Our callback function, for when a feed is loaded.
function feedLoaded(result) {
if (!result.error) {
// Grab the container we will put the results into
var container = document.getElementById("Result");
container.innerHTML = '';
// Loop through the feeds, putting the titles onto the page.
// Check out the result object for a list of properties
returned in each entry.
//
http://code.google.com/apis/ajaxfeeds/documentation/reference.html#JSON
for (var i = 0; i < result.feed.entries.length; i++) {
var entry = result.feed.entries[i];
var div = document.createElement("div");
div.appendChild(document.createTextNode(entry.title));
container.appendChild(div);
}
}
}
function OnLoad() {
// Create a feed instance that will grab Digg's feed.
var feed = new google.feeds.Feed("http://mf.feeds.reuters.com/
reuters/UKStocksAndSharesNews");
//feed.includeHistoricalEntries(); // tell the API we want to
have old entries too
feed.setNumEntries(2); // we want a maximum of 100 entries, if
they exist
// Calling load sends the request off. It requires a callback
function.
feed.load(feedLoaded);
}
google.setOnLoadCallback(OnLoad);
</script>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google AJAX APIs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-ajax-search-api?hl=en
-~----------~----~----~----~------~----~------~--~---