I am new to using Appcelerator and having some difficulty performing a task that should be relatively simple. I am trying to retrieve an RSS feed and then display each entry in a TableView; grabbing the entries is working fine but I cannot seem to figure out how to then pass the results on to the TableView element.
I have found a lot of tutorials that tackle this for Titanium (usually 2+ years old) but I really want to use Alloy. I learned how to iterate over items in a Model but in this case we're fetching RSS data.
Here is the code I have so far:
index.js
var data =[];
var x = 0;
var xhr = Ti.Network.createHTTPClient();
xhr.open("GET", "https://somewhere.org/feed");
xhr.onload = function() {
try {
var doc = this.responseXML.documentElement;
var items = doc.getElementsByTagName("entry");
var x = 0;
for(var c = 0; c<items.length;c++) {
var item = items.item(c);
var name = item.getElementsByTagName("name").item(0).text;
var row = {'name' : name};
data[x++] = row;
}
} catch(E) {
alert(E);
}
};
xhr.send();
$.index.open();
index.xml
<Alloy>
<Window class="container">
<TableView>
<TableViewRow title="{name}"></TableViewRow>
</TableView>
</Window>
Any help would be appreciated.