<jupyter_start><jupyter_text>Final code - generate xpressegnine sitemap<jupyter_code>def set_date(raw_date):
    raw_date = raw_date[:4] + '-' + raw_date[4:]
    val_date = raw_date[:7] + '-' + raw_date[7:]
    return val_date
%%time
import xml.etree.cElementTree as ET

d = {'xmlns':'http://www.sitemaps.org/schemas/sitemap/0.9'}  # root dict
root = ET.Element("urlset", d)

for tup1 in res:
    url = ET.SubElement(root, "url")
    loc = tup1[5]
    lastmod = set_date(tup1[3]) 
    changefreq = tup1[7]
    priority = str(tup1[8])
    ET.SubElement(url, "loc").text = loc
    ET.SubElement(url, "lastmod").text = lastmod
    ET.SubElement(url, "changefreq").text = changefreq
    ET.SubElement(url, "priority").text = priority

tree = ET.ElementTree(root)

# set ET to str
str_xml = ET.tostring(root, encoding="utf-8", xml_declaration=True).decode('utf-8')

# write to siteml.xml file
text_file = open("sitemap.xml", "w", encoding="utf-8")
text_file.write(str_xml)
text_file.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16453201970443349, 'fraction_numerical': 0.017733990147783252, 'mean_word_length': 4.433155080213904, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 7}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '393795', 'license': 'MIT', 'n_tokens_mistral': 407, 'n_tokens_neox': 401, 'n_words': 73, 'path': 'sitemap.ipynb', 'repo_name': 'CloudBreadPaPa/xpressengine_sitemap_python', 'size': '1015'}