Simple script for beginning developer

Topic Labels: Scripting extentions
1577 3
Showing results for 
Search instead for 
Did you mean: 
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi everyone! I’m a long-time Airtable user and novice developer. I’m currently teaching myself Javascript and have a small script I’m trying to create (at least I think it’s small/simple).

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”

Screen Shot 2020-03-18 at 11.45.51 AM

So far, I’ve been able to figure out that I can use a bit of javascript to count the number of xml nodes in a document using something like this:

var x = xmlDoc.getElementsByTagName("loc");

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?


3 Replies 3
10 - Mercury
10 - Mercury

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");

good luck!

Ahhh thank you so much! This is very helpful for getting started, especially the fetch function and DOMParser

Did you get any errors at first with DOMParser?

I’m getting:
ReferenceError: DOMParser is not defined

From my understanding this isn’t supported?