FAQ // All answers
How do I convert an XML sitemap to CSV in Python?
Python's standard library handles this in about 15 lines. Use urllib.request.urlopen to fetch the sitemap, xml.etree.ElementTree to parse it, and the csv module to write rows. The one gotcha is the XML namespace — sitemap files declare xmlns="http://www.sitemaps.org/schemas/sitemap-0.9", so you need to use the namespace prefix in your findall, e.g. root.findall('{http://www.sitemaps.org/schemas/sitemap-0.9}url'). For sitemap-index files, recurse into each child sitemap. Skip BeautifulSoup unless you also need to parse HTML sitemaps — for pure XML, etree is faster and ships with Python. If you don't want to write code, the xmlsitemapmaker.com converter does the same thing through a URL.
RELATED