{"id":143,"date":"2019-05-25T14:18:43","date_gmt":"2019-05-25T14:18:43","guid":{"rendered":"http:\/\/www.countingcharacters.com\/blog\/?p=143"},"modified":"2021-12-19T11:16:27","modified_gmt":"2021-12-19T11:16:27","slug":"extract-xml-sitemap-urls","status":"publish","type":"post","link":"https:\/\/www.countingcharacters.com\/blog\/extract-xml-sitemap-urls\/","title":{"rendered":"How to Extract XML Sitemap URLs in Google Sheets?"},"content":{"rendered":"\n<p>In this tutorial, you will learn how to extract URLs from a XML sitemap using a custom function of Google sheets. <br><br><strong>Follow these steps to extract URLs of XML sitemap:<\/strong><\/p>\n\n\n\n<ol><li>Let&#8217;s start, first get the URL of XML sitemap from you want to extract URLs. eg: www.example.com\/sitemap.xml.<br><\/li><li> Now you need to create a new Google spreadsheet. Type <a href=\"http:\/\/sheets.new\" target=\"_blank\" rel=\"noreferrer noopener\">sheets.new<\/a> in the URL bar to create a new Google spreadsheet. <br><\/li><li>Now, go to menu bar and select script editor under the tools option.<br><br><figure><img decoding=\"async\" loading=\"lazy\" width=\"680\" height=\"413\" class=\"wp-image-151\" style=\"width: 800px;\" src=\"http:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2019\/05\/google-sheets-script.png\" alt=\"Google Sheets Script Editor\" srcset=\"https:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2019\/05\/google-sheets-script.png 680w, https:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2019\/05\/google-sheets-script-300x182.png 300w\" sizes=\"(max-width: 680px) 100vw, 680px\" \/><\/figure><\/li><li>Now you will redirect to script page, in this script page, we will create a custom JavaScript function. For this copy below code and paste into your script editor and save it with your desire name. <br><br><figure><img decoding=\"async\" loading=\"lazy\" width=\"848\" height=\"390\" class=\"wp-image-154\" style=\"width: 900px;\" src=\"http:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2019\/05\/google-sheets-script-editor.png\" alt=\"Google Sheets Script Editor\" srcset=\"https:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2019\/05\/google-sheets-script-editor.png 848w, https:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2019\/05\/google-sheets-script-editor-300x138.png 300w, https:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2019\/05\/google-sheets-script-editor-768x353.png 768w\" sizes=\"(max-width: 848px) 100vw, 848px\" \/><\/figure><\/li><\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n* Returns URLs in sitemap.xml file\n*\n* @param {\"https:\/\/www.google.com\/gmail\/sitemap.xml\"} sitemapUrl REQUIRED The url of the sitemap\n* @param {\"http:\/\/www.sitemaps.org\/schemas\/sitemap\/0.9\"} namespace REQUIRED Look at the source of the xml sitemap, look for the xmlns value \n* @return Returns urls &lt;loc&gt; from an xml sitemap\n* @customfunction\n*\/\n\nfunction sitemap(sitemapUrl,namespace) {\n  \n  try {\n    var xml = UrlFetchApp.fetch(sitemapUrl).getContentText();\n    var document = XmlService.parse(xml);\n    var root = document.getRootElement()\n    var sitemapNameSpace = XmlService.getNamespace(namespace);\n    \n    var urls = root.getChildren('url', sitemapNameSpace)\n    var locs = &#91;]\n    \n    for (var i=0;i &lt;urls.length;i++) {\n      locs.push(urls&#91;i].getChild('loc', sitemapNameSpace).getText()) \n    }\n    \n    return locs  \n  } catch (e) {\n    return e \n  }\n}<\/code><\/pre>\n\n\n\n<p><strong>Now formula has been created, continue to next process:<\/strong><\/p>\n\n\n\n<ol><li>Get back to sheet and type <strong>=sitemapurl()<\/strong> which is the function name that we have created in the script editor.<br><figure><img decoding=\"async\" loading=\"lazy\" width=\"647\" height=\"348\" class=\"wp-image-155\" style=\"width: 800px;\" src=\"http:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2019\/05\/sitemap-custom-function-google-sheets.png\" alt=\"Sitemap Custom Function Google Sheets\" srcset=\"https:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2019\/05\/sitemap-custom-function-google-sheets.png 647w, https:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2019\/05\/sitemap-custom-function-google-sheets-300x161.png 300w\" sizes=\"(max-width: 647px) 100vw, 647px\" \/><\/figure><\/li><li>This function requires two parameters, first is sitemap URL (<strong>eg: http:\/\/www.countingcharacters.com\/sitemap.xml<\/strong>) and second is namespace (<strong>eg: http:\/\/www.sitemaps.org\/schemas\/sitemap\/0.9<\/strong>) of sitemap.<br><figure><img decoding=\"async\" loading=\"lazy\" width=\"786\" height=\"339\" class=\"wp-image-156\" style=\"width: 800px;\" src=\"http:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2019\/05\/sitemap-custom-formula-google-sheets.png\" alt=\"Google Sheet Formula to Extract Sitemap URLs\" srcset=\"https:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2019\/05\/sitemap-custom-formula-google-sheets.png 786w, https:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2019\/05\/sitemap-custom-formula-google-sheets-300x129.png 300w, https:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2019\/05\/sitemap-custom-formula-google-sheets-768x331.png 768w\" sizes=\"(max-width: 786px) 100vw, 786px\" \/><\/figure><\/li><li>After putting the parameters, press enter to run a function.<br><\/li><li>Now it&#8217;s done, you can see the list of URLs that are present in your sitemap.<br><\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"884\" height=\"304\" src=\"https:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2021\/12\/image.png\" alt=\"extract urls from xml sitemap\" class=\"wp-image-360\" srcset=\"https:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2021\/12\/image.png 884w, https:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2021\/12\/image-300x103.png 300w, https:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2021\/12\/image-768x264.png 768w\" sizes=\"(max-width: 884px) 100vw, 884px\" \/><\/figure>\n\n\n\n<p>I hope you understand the XML sitemap URLs extracting process by using the custom function of Google sheets.<\/p>\n\n\n\n<p>If you are interested in Google sheets formulas, so you should also read this blog that about <a href=\"https:\/\/www.countingcharacters.com\/blog\/google-sheets-importxml\/\">IMPORTXML<\/a> function.<\/p>\n\n\n\n<p>Still, you have any query, please let me know in the comment section.<\/p>\n\n\n\n<p>If you learned something valuable, please share with others. \u2764\ud83d\udc4d<\/p>\n\n\n\n<a href=\"https:\/\/docs.google.com\/spreadsheets\/d\/1jKP30CAJEL-rQ8PUnkNfJOiBfDN1XWNauTEUxBU1-w8\/copy\"><button style-\"margin:10px;\"=\"\">See Demo, Make Copy of Sheet<\/button><\/a>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn how to extract URLs from a XML sitemap using a custom function of Google sheets. Follow these steps to extract URLs of XML sitemap: Let&#8217;s start, first get the URL of XML sitemap from you want to extract URLs. eg: www.example.com\/sitemap.xml. Now you need to create a new Google [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":156,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,3],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v17.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Extract URLs from a XML Sitemap? [Using Google Sheets]<\/title>\n<meta name=\"description\" content=\"In this guide, I will show you how to extract URLs from a XML sitemap using Google Sheets. To learn the full process of sitemap URLs extracting, read this post now!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.countingcharacters.com\/blog\/extract-xml-sitemap-urls\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Extract URLs from a XML Sitemap? [Using Google Sheets]\" \/>\n<meta property=\"og:description\" content=\"In this guide, I will show you how to extract URLs from a XML sitemap using Google Sheets. To learn the full process of sitemap URLs extracting, read this post now!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.countingcharacters.com\/blog\/extract-xml-sitemap-urls\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Counting Characters\" \/>\n<meta property=\"article:published_time\" content=\"2019-05-25T14:18:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-12-19T11:16:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2019\/05\/sitemap-custom-formula-google-sheets.png\" \/>\n\t<meta property=\"og:image:width\" content=\"786\" \/>\n\t<meta property=\"og:image:height\" content=\"339\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mohit Harjai\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.countingcharacters.com\/blog\/#website\",\"url\":\"https:\/\/www.countingcharacters.com\/blog\/\",\"name\":\"Blog - Counting Characters\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.countingcharacters.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.countingcharacters.com\/blog\/extract-xml-sitemap-urls\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2019\/05\/sitemap-custom-formula-google-sheets.png\",\"contentUrl\":\"https:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2019\/05\/sitemap-custom-formula-google-sheets.png\",\"width\":786,\"height\":339,\"caption\":\"Google Sheet Formula to Extract Sitemap URLs\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.countingcharacters.com\/blog\/extract-xml-sitemap-urls\/#webpage\",\"url\":\"https:\/\/www.countingcharacters.com\/blog\/extract-xml-sitemap-urls\/\",\"name\":\"How to Extract URLs from a XML Sitemap? [Using Google Sheets]\",\"isPartOf\":{\"@id\":\"https:\/\/www.countingcharacters.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.countingcharacters.com\/blog\/extract-xml-sitemap-urls\/#primaryimage\"},\"datePublished\":\"2019-05-25T14:18:43+00:00\",\"dateModified\":\"2021-12-19T11:16:27+00:00\",\"author\":{\"@id\":\"https:\/\/www.countingcharacters.com\/blog\/#\/schema\/person\/42edab7be3c3c5054649c5ff3c234b5f\"},\"description\":\"In this guide, I will show you how to extract URLs from a XML sitemap using Google Sheets. To learn the full process of sitemap URLs extracting, read this post now!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.countingcharacters.com\/blog\/extract-xml-sitemap-urls\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.countingcharacters.com\/blog\/extract-xml-sitemap-urls\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.countingcharacters.com\/blog\/extract-xml-sitemap-urls\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.countingcharacters.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Extract XML Sitemap URLs in Google Sheets?\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.countingcharacters.com\/blog\/#\/schema\/person\/42edab7be3c3c5054649c5ff3c234b5f\",\"name\":\"Mohit Harjai\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.countingcharacters.com\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5e9de236da67b39efeabc42863395e36?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/5e9de236da67b39efeabc42863395e36?s=96&d=mm&r=g\",\"caption\":\"Mohit Harjai\"},\"description\":\"He is fond of digital marketing skills and loves to do creative things in a digital planet.\",\"sameAs\":[\"https:\/\/www.countingcharacters.com\"],\"url\":\"https:\/\/www.countingcharacters.com\/blog\/author\/mohitharjai\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Extract URLs from a XML Sitemap? [Using Google Sheets]","description":"In this guide, I will show you how to extract URLs from a XML sitemap using Google Sheets. To learn the full process of sitemap URLs extracting, read this post now!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.countingcharacters.com\/blog\/extract-xml-sitemap-urls\/","og_locale":"en_US","og_type":"article","og_title":"How to Extract URLs from a XML Sitemap? [Using Google Sheets]","og_description":"In this guide, I will show you how to extract URLs from a XML sitemap using Google Sheets. To learn the full process of sitemap URLs extracting, read this post now!","og_url":"https:\/\/www.countingcharacters.com\/blog\/extract-xml-sitemap-urls\/","og_site_name":"Blog - Counting Characters","article_published_time":"2019-05-25T14:18:43+00:00","article_modified_time":"2021-12-19T11:16:27+00:00","og_image":[{"width":786,"height":339,"url":"https:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2019\/05\/sitemap-custom-formula-google-sheets.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_misc":{"Written by":"Mohit Harjai","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/www.countingcharacters.com\/blog\/#website","url":"https:\/\/www.countingcharacters.com\/blog\/","name":"Blog - Counting Characters","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.countingcharacters.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https:\/\/www.countingcharacters.com\/blog\/extract-xml-sitemap-urls\/#primaryimage","inLanguage":"en-US","url":"https:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2019\/05\/sitemap-custom-formula-google-sheets.png","contentUrl":"https:\/\/www.countingcharacters.com\/blog\/wp-content\/uploads\/2019\/05\/sitemap-custom-formula-google-sheets.png","width":786,"height":339,"caption":"Google Sheet Formula to Extract Sitemap URLs"},{"@type":"WebPage","@id":"https:\/\/www.countingcharacters.com\/blog\/extract-xml-sitemap-urls\/#webpage","url":"https:\/\/www.countingcharacters.com\/blog\/extract-xml-sitemap-urls\/","name":"How to Extract URLs from a XML Sitemap? [Using Google Sheets]","isPartOf":{"@id":"https:\/\/www.countingcharacters.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.countingcharacters.com\/blog\/extract-xml-sitemap-urls\/#primaryimage"},"datePublished":"2019-05-25T14:18:43+00:00","dateModified":"2021-12-19T11:16:27+00:00","author":{"@id":"https:\/\/www.countingcharacters.com\/blog\/#\/schema\/person\/42edab7be3c3c5054649c5ff3c234b5f"},"description":"In this guide, I will show you how to extract URLs from a XML sitemap using Google Sheets. To learn the full process of sitemap URLs extracting, read this post now!","breadcrumb":{"@id":"https:\/\/www.countingcharacters.com\/blog\/extract-xml-sitemap-urls\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.countingcharacters.com\/blog\/extract-xml-sitemap-urls\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.countingcharacters.com\/blog\/extract-xml-sitemap-urls\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.countingcharacters.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Extract XML Sitemap URLs in Google Sheets?"}]},{"@type":"Person","@id":"https:\/\/www.countingcharacters.com\/blog\/#\/schema\/person\/42edab7be3c3c5054649c5ff3c234b5f","name":"Mohit Harjai","image":{"@type":"ImageObject","@id":"https:\/\/www.countingcharacters.com\/blog\/#personlogo","inLanguage":"en-US","url":"https:\/\/secure.gravatar.com\/avatar\/5e9de236da67b39efeabc42863395e36?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5e9de236da67b39efeabc42863395e36?s=96&d=mm&r=g","caption":"Mohit Harjai"},"description":"He is fond of digital marketing skills and loves to do creative things in a digital planet.","sameAs":["https:\/\/www.countingcharacters.com"],"url":"https:\/\/www.countingcharacters.com\/blog\/author\/mohitharjai\/"}]}},"_links":{"self":[{"href":"https:\/\/www.countingcharacters.com\/blog\/wp-json\/wp\/v2\/posts\/143"}],"collection":[{"href":"https:\/\/www.countingcharacters.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.countingcharacters.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.countingcharacters.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.countingcharacters.com\/blog\/wp-json\/wp\/v2\/comments?post=143"}],"version-history":[{"count":27,"href":"https:\/\/www.countingcharacters.com\/blog\/wp-json\/wp\/v2\/posts\/143\/revisions"}],"predecessor-version":[{"id":361,"href":"https:\/\/www.countingcharacters.com\/blog\/wp-json\/wp\/v2\/posts\/143\/revisions\/361"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.countingcharacters.com\/blog\/wp-json\/wp\/v2\/media\/156"}],"wp:attachment":[{"href":"https:\/\/www.countingcharacters.com\/blog\/wp-json\/wp\/v2\/media?parent=143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.countingcharacters.com\/blog\/wp-json\/wp\/v2\/categories?post=143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.countingcharacters.com\/blog\/wp-json\/wp\/v2\/tags?post=143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}