Mar 18, 2020 08:56 AM
I want to create a script that loops through a list of sitemap urls and returns the total count of pages for each record to a field in my table called “Page Count”
var x = xmlDoc.getElementsByTagName("loc"); return(x.length);
But I’m not sure how to pull in an xml doc hosted at a specific url or loop through airtable records…anyone willing to provide a little direction?
Mar 18, 2020 10:14 AM
you would want to use the fetch() function. something like:
let urlContent = await fetch(sitemapLink) let text = await urlContent.body()
let to convert that to an xml doc:
let parser = new DOMParser(); xmlDoc = parser.parseFromString(text,"text/xml");
Mar 18, 2020 04:15 PM
Ahhh thank you so much! This is very helpful for getting started, especially the fetch function and DOMParser
May 11, 2020 08:40 AM
Did you get any errors at first with DOMParser?
ReferenceError: DOMParser is not defined
From my understanding this isn’t supported?