Hi,
this is kind of like a generic question. Upfront: I have no experience in Javascript and yes, will be looking deeper into the topic and start grinding and learn it for the sake of weweb.
I have this javascript
const xmlData = `
// Your XML data goes here
`;
function getCommaSeparatedUrls(xml) {
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xml, "text/xml");
const sitemapNodes = xmlDoc.getElementsByTagName("loc");
const urls = [];
for (let i = 0; i < sitemapNodes.length; i++) {
urls.push(sitemapNodes[i].textContent);
}
return urls.join(", ");
}
const commaSeparatedUrls = getCommaSeparatedUrls(xmlData);
this is supposed to parse an xml sitemap for the urls that it contains. Unfortunately it does not output a result.
As I said, I have no experience with it and rely on pointers in this case on what could be the issue.
Am I doing the Javascript in weweb thing right at all? Are there limitations, differences to a “standard” script anywhere else? Really no clue here right now. (Sorry for the ignorance)
I have it placed in a workflow, currently simply making a variable with the returned output. And sure, in the real situation I am feeding it the real data. Even tried it with the xml hardcoded into the script above.
Still no results.