[Answer]-How to check if the sitemap contain some urls

1👍

You could use ElementTree to parse xml:

from xml.etree import ElementTree as etree

urlset = etree.fromstring(xml)
if urlset.find('url') is None:
   print("sitemap has no urls") 
👤jfs

0👍

Surely your bug is a direct consequence of a much more important bug – your django app has no urls in it!

Fix this and your sitemap bug goes away. What’s the point in a site map with no site?

UPDATE

I don’t completely understand how it will help, but if you want to parse xml then python’s built in ElementTree library might be what you’re looking for. And there’s more here from the python site.

Leave a comment