如何在谷歌应用程序脚本中解析提要的每个项目的标题



我试图简单地解析RSS提要,但遇到了一个错误。我怎样才能得到";标题";每个项目?上面写着";无法读取null的属性"getText">

我不知道如何调试它。

function parseFeed() {
var feed = UrlFetchApp.fetch("https://www.reddit.com/r/GoogleAppsScript.rss?limit=1000").getContentText();
feed = XmlService.parse(feed);
var namespace = XmlService.getNamespace("http://www.w3.org/2005/Atom");
var items = feed.getRootElement().getChildren("entry", namespace);  
items.forEach(item => {
var title = item.getChild('title').getText();
Logger.log(title);
});
}

当您的显示脚本被修改时,下面的修改如何?

发件人:

var title = item.getChild('title').getText();

收件人:

var title = item.getChild('title', namespace).getText();

最新更新