Analyse sitemap.xml file with importXML in Google Spreadsheets

Terry (Thang) Pham
1 min readMay 25, 2017

Working with the sitemap.xml file can be a bit tricky, especially if you struggle to remember the formulas. But fret not! I’ve got you covered. Here are some handy codes that you can use with Google Spreadsheets:

1. Importing all URLs from the sitemap.xml file:
Use this code to fetch all the URLs from your sitemap file. Just replace the link with your own sitemap URL (e.g., https://www.example.com/sitemap.xml).

=IMPORTXML(“https://www.example.com/sitemap.xml", “//*[local-name() =’url’]/*[local-name() =’loc’]”, ”lang_locate”)

2. Getting the title of a page from its URL:
This code extracts the page title, which is usually enclosed within the `<title>` tag.

=IMPORTXML(“https://www.example.com/sample-url", “//title/text()”, , ”lang_locate”)

3. Retrieving the meta description of a page from its URL:
Use this code to fetch the meta description of a page. The meta description is usually found within the `<meta name=”description” content=”sample content”>` tag.

=IMPORTXML(“https://www.example.com/sample-url", “//meta[@name=’description’]/@content”, ”lang_locate”)

Feel free to jot down these codes for your future reference, and don’t forget to share them with others who might find them helpful. Happy sitemap.xml hacking!

--

--