Google Apps ScriptGoogle Docs

Extract URLs from XML Sitemaps in Google sheets

Get the Script > GitHub repository here

Installation

  1. Copy the code from the GitHub repository onto your clipboard
  2. Open a new Google sheet
  3. Tools > Script editor, and paste in the code
  4. Hit save, name your project
  5. Run either one of the functions to get the authorization prompt – the function will fail but it doesn’t matter, we’re just setting the auth permissions
  6. Done! Go to your spreadsheet and use the formulas

See it in action

Methods

sitemap(sitemapUrl, namespace)

Returns URLs in sitemap.xml file
Parameters:
NameExampleDescription
sitemapUrl“https://www.google.com/gmail/sitemap.xml”REQUIRED The url of the sitemap
namespace“http://www.sitemaps.org/schemas/sitemap/0.9”REQUIRED Look at the source of the xml sitemap, look for the xmlns value

sitemapIndex(sitemapIndexUrl, namespace)

Returns URLs in sitemap index file

Parameters:
NameExampleDescription
sitemapIndexUrl“https://www.google.com/sitemap.xml”REQUIRED The url of the sitemap
namespace“http://www.sitemaps.org/schemas/sitemap/0.9”REQUIRED Look at the source of the xml sitemap, look for the xmlns value
David Sottimano

About David Sottimano

Founder of OpensourceSeo.org. Strategist at definemg.com