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.
- [Answer]-How to add is_client method to User model in Django with these models?
- [Answer]-Django templates decimal separator with safe tag
- [Answer]-Django – How to break the HTML code in file
Source:stackexchange.com