'How do I selectively extract Loc alone from the below code? I dont need other elements
I am trying to just separate LOC field from the output and store it as an array in the format urls = [loc1, loc2, loc3 ....]. Can someone guide me please? I am rookie programmer
const SitemapXMLParser = require('sitemap-xml-parser');
const url = 'something sitemap url';
/*
If sitemapindex (link of xml or gz file) is written in sitemap, the URL will be accessed.
You can optionally specify the number of concurrent accesses and the number of milliseconds after processing and access to resume processing after a delay.
*/
const options = {
delay: 3000,
limit: 5
};
const sitemapXMLParser = new SitemapXMLParser(url, options);
sitemapXMLParser.fetch().then(result => {
console.log(result);
});
/*
Returns
{
loc: [ --- ],
lastmod: [ --- ],
changefreq: [ --- ],
priority: [ --- ]
},
{
loc: [ --- ],
lastmod: [ --- ],
changefreq: [ --- ],
priority: [ --- ]
},
...
*/
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
