Skip to content

Instantly share code, notes, and snippets.

@erikakers
Created March 19, 2014 20:58
Show Gist options
  • Select an option

  • Save erikakers/9651093 to your computer and use it in GitHub Desktop.

Select an option

Save erikakers/9651093 to your computer and use it in GitHub Desktop.
Parsing an XML feed in to a json data model.
loadResultSnippits: function(results){
var documents = [];
for(var i = 0; i < results.length; i++){
var url = $(results[i]).attr('url'),
title = $(results[i]).find('content[name="title"]').text(),
fileType = $(results[i]).find('content[name="filetype"]').text(),
language = $(results[i]).find('content[name="language"]').text(),
date = $(results[i]).find('content[name="last-modified"]').text().substring(0, 14),
snippet = $(results[i]).find('content[name="snippet"]').text();
documents.push({
"url" : url,
"title": title,
"filetype": fileType,
"language": language,
"date": date,
"snippet": snippet
});
}
this.compileTemplate(documents);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment