[reportlab-users] xml parser error (bogus < or &) in paragrap

Claudio Battaglino c.battaglino at icube.it
Tue Nov 22 12:53:29 EST 2005


Hi,
I've an error if a Paragraph contains some characters such as "&".
I found something in the mailing list archive, but I didn't understand 
how to fix the problem.
How can I escape these chars?

This is a simple example that raises the exception (test.py):


from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib.units import inch
styles = getSampleStyleSheet()

def printPDF():
     doc = SimpleDocTemplate("test.pdf")
     Story = []
     style = styles["Normal"]
     bogustext = ("Starsky & Hutch")
     p = Paragraph(bogustext, style)
     Story.append(p)
     doc.build(Story)

if __name__=="__main__":
     printPDF()


#python test.py

Traceback (most recent call last):
   File "prova.py", line 19, in ?
     printPDF()
   File "prova.py", line 12, in printPDF
     p = Paragraph(bogustext, style)
   File 
"/var/local/python/lib/python2.3/site-packages/reportlab/platypus/paragraph.py", 
line 378, in __init__
     self._setup(text, style, bulletText, frags, cleanBlockQuotedText)
   File 
"/var/local/python/lib/python2.3/site-packages/reportlab/platypus/paragraph.py", 
line 403, in _setup
     raise "xml parser error (%s) in paragraph beginning\n'%s'"\
xml parser error (bogus < or &) in paragraph beginning
'Starsky & Hutch'


thank you very much

Claudio B.


More information about the reportlab-users mailing list