How to encode html and xml tag datas with standard python modules?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DurumDara

    #1

    How to encode html and xml tag datas with standard python modules?

    Hi !

    Have the python standard mod. lib. a html/xml encoder functions/procedures ?

    like this:

    def ToSafeHTM(Text) :
    s=ToHuStrSafe(T ext)
    l=[]
    for c in s:
    b=ord(c)
    if c=="\n":
    c="<br>"
    else:
    if b<32 or b>127 or c in ['<','>','"',';' ,'&','@','%','# ']:
    c="&#%03d;"%b
    l.append(c)
    s="".join(l)
    return s

    Thanx for help:
    dd
Working...