I am trying to populate a table with articles pulled from a PubMed search. The way I understand it I have to first search for 2 pieces of information from PubMed: WebEnv and QueryKey.
http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgidb=pubmed&term=aorta&usehistory=y&rettype=xml&retmax=10
I get this:
<QueryKey>1</QueryKey> <WebEnv> NCID_1_55462841_130.14.22.215_9001_1387150273_1082905125 </WebEnv>Then I have to query PubMed again for the XML data.
http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&query_key=" + QueryKey + "&WebEnv=" + WebEnv + "&rettype=xml&retmax=10
I am have been trying to figure this out for the past 2 days and I am sure if I am not even on the right track.
function xml_rss(_args) { var url = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=aorta&usehistory=y&rettype=xml&retmax=10"; var win = Ti.UI.createWindow(); var table = Ti.UI.createTableView(); var tableData = []; var json, fighters, fighter, i, row, nameLabel, nickLabel; var xhr = Ti.Network.createHTTPClient({ onload : function() { // Ti.API.debug(this.responseText); var doc = this.responseXML.documentElement; var WebEnv = doc.getElementsByTagName("WebEnv"); var QueryKey = doc.getElementsByTagName("QueryKey"); var url1 = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&query_key=" + QueryKey + "&WebEnv=" + WebEnv + "&rettype=xml&retmax=10"; var xhr1 = Ti.Network.createHTTPClient({ onload : function() { var articles = xml.getElementsByTagName("PubmedArticle"); for ( var i = 0; i < articles.length; i++) { var row = Ti.UI.createTableViewRow({ height : '60dp' }); var nameLabel = Ti.UI.createLabel({ text : articles[i].getElementsByTagName("PMID")[0].firstChild.nodeValue, font : { fontSize : '24dp', fontWeight : 'bold' }, height : 'auto', left : '10dp', top : '5dp', color : '#000', touchEnabled : false }); row.add(nameLabel); tableData.push(row); } table.setData(tableData); }, onerror : function(e) { Ti.API.debug("STATUS: " + this.status); Ti.API.debug("TEXT: " + this.responseText); Ti.API.debug("ERROR: " + e.error); alert('There was an error retrieving the remote data. Try again.'); }, timeout : 5000 }); xhr1.open("GET", url1); xhr1.send(); }, onerror : function(e) { Ti.API.debug("STATUS: " + this.status); Ti.API.debug("TEXT: " + this.responseText); Ti.API.debug("ERROR: " + e.error); alert('There was an error retrieving the remote data. Try again.'); }, timeout : 5000 }); xhr.open("GET", url); xhr.send(); win.add(table); return win; }; module.exports = xml_rss;