I'm trying to render my sitemap.xml
using flask
, however I cannot seem to clean my input such that the rendering can work. The error is the following:
error on line 23325 at column 83: PCDATA invalid Char value 11
The code I'm using is:
url = prepend + "/explore/"+str(result['id'])+"/"+result['title'].encode('utf-8', 'xmlcharrefreplace').decode('utf-8')
I've also tried:
url = prepend + "/explore/"+str(result['id'])+"/"+result['title'].encode('ascii', 'xmlcharrefreplace').decode('ascii')
Also removing what is Char 11, doesn't seem to work either.
result["title"] = result["title"].replace('', '')
Is there a smarter way that I can clean any spurious characters or problem solve more accurately?
I've tried to flag the problem. It looks like a linefeed or something along those lines. I've tried before and after the URL is built.
XX XXX XXX XXX
Step by step guide
but, I cannot find anything in the python arsenal to remove the linefeed. I'm trying, replace('\r', '')
, strip()
etc etc, but still this persists.