Create page tree with sitemap xml

import org.jsoup.Jsoup;
import info.magnolia.jcr.util.NodeUtil;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;


pageTemplate = "light-development-module:pages/article"
rootNode = "/moz"
removeDomain = "https://moz.com"
sitemapurl = "https://moz.com/sitemaps-1-section-blog-1-sitemap.xml"


websitehm = MgnlContext.getInstance().getJCRSession('website')
List<String> urlList = new ArrayList<>();
Document doc = Jsoup.connect(sitemapurl).get();
Elements urls = doc.getElementsByTag("loc");

for (Element url : urls) {
	urlName = url.text();
	println(rootNode + urlName.replace(removeDomain, ""))
	node = NodeUtil.createPath(websitehm.getNode("/"), rootNode + urlName.replace(removeDomain, ""), "mgnl:page")
	node.setProperty("mgnl:template", pageTemplate)
}
websitehm.save()

return "page tree created"