Google Apps ScriptでRSS取得ソート

function googlenewsRSS() {
  
  var sheet = SpreadsheetApp.getActiveSheet(); 
  
  var row = 1;
  
  var feedURL = 'https://news.google.com/news/feeds?ned=us&ie=UTF-8&oe=UTF-8&q=%E4%BB%8A%E6%B2%BB&output=atom&num=30&hl=ja';
  
  var xml = UrlFetchApp.fetch(feedURL).getContentText();
  var document = XmlService.parse(xml);
  var root = document.getRootElement();
  var atom = XmlService.getNamespace('http://www.w3.org/2005/Atom');
  
  var entries = root.getChildren('entry', atom);
  
  for(i in entries) {
    var title = entries[i].getChild('title', atom).getText();
    var id = entries[i].getChild('id', atom).getText();
    
    var tempid = id.split('=');
    var url = tempid[1];
    var updated = entries[i].getChild('updated', atom).getText();
    
    sheet.getRange(row,1).setValue(title);
    sheet.getRange(row,2).setValue(url);
    sheet.getRange(row,3).setValue(updated);
    
    row++;
    }
  sheet.sort(3, false);  //日付逆順ソート
}

imabari.hateblo.jp