[Tutor] Convert XML codes to "normal" text?

Sander Sweers sander.sweers at gmail.com
Wed Mar 4 22:40:34 CET 2009


2009/3/4 Eric Dorsey <dorseye at gmail.com>:
> d = feedparser.parse('http://snipt.net/dorseye/feed')
>
> x=0
> for i in d['entries']:
>     print d['entries'][x].title
>     print d['entries'][x].summary
>     print
>     x+=1
>
> Output
>
> Explode / Implode List
> &gt;&gt;&gt; V = list(V)

<snip>

> I know, for example, that the &gt; code means >, but what I don't know is
> how to convert it in all my data to show properly? In all the feedparser

<snip>

What you are looking for is unescape from saxutils. Example:

>>> from xml.sax.saxutils import unescape
>>> unescape('&gt;')
'>'

Greets
Sander


More information about the Tutor mailing list