I am pretty new to Google Apps Scripts. I am using a script that pulls the URLs from an XML sitemap into Google Spreadsheets. I need it to be time-based so that it will pull in the new URLs when they are added.
I have added a trigger to my code via project triggers. The trigger seems to run but the spreadsheet is not updated with the new URLs.
I am using the following code
function sitemap(sitemapUrl,namespace) {
try {
var xml = UrlFetchApp.fetch(sitemapUrl).getContentText();
var document = XmlService.parse(xml);
var root = document.getRootElement()
var sitemapNameSpace = XmlService.getNamespace(namespace);
var urls = root.getChildren('url', sitemapNameSpace)
var locs = []
for (var i=0;i <urls.length;i++) {
locs.push(urls[i].getChild('loc', sitemapNameSpace).getText())
}
return locs
} catch (e) {
return e
}
}
The script is working fine but the problem is that it does not update the information according to the trigger I have created. Does anyone have a suggestion on how to solve this?
setValues()
? – sinaraheneba