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

Robin Becker robin at reportlab.com
Tue Nov 22 13:40:32 EST 2005


Claudio Battaglino wrote:
> 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'
> 
....use Starsky &amp; Hutch

-- 
Robin Becker


More information about the reportlab-users mailing list