[Twisted-Python] XML parsing on twisted
Hello, I went to use the SAX library to perform parsing. However I hit an unusual problem. Its having a problem parsing a token that has a '&' it just crashes. It certainly woke me up when I witnessed this. <books> Jim & Nancy </books> are passed to the ContentHandler class. When characters(self,chars) member gets called I perform self.book+=chars to reassemble the string. I dump out the self.book string as its being assembled. If I replace the '&' character with "and" then its Ok. Of course I dont want to have to replace '&' with 'and'. Not good. So has anybody else seen this problem. I'm assuming it thinks its a reference and becomes confused when I attempt to add a reference. Much appreciated, Garyc
Hi, 2009/10/4 gary clark <burslem2001@yahoo.com>:
Hello,
I went to use the SAX library to perform parsing. However I hit an unusual problem.
Its having a problem parsing a token that has a '&' it just crashes. It certainly woke me up when I witnessed this.
<books> Jim & Nancy </books>
are passed to the ContentHandler class. When characters(self,chars) member gets called I perform self.book+=chars to reassemble the string.
I dump out the self.book string as its being assembled. If I replace the '&' character with "and" then its Ok. Of course I dont want to have to replace '&' with 'and'.
Not good. So has anybody else seen this problem. I'm assuming it thinks its a reference and becomes confused when I attempt to add a reference.
Much appreciated,
the & character is a special character in XML. You are parsing an invalid XML string. This page says it well: http://www.devx.com/tips/Tip/14068 (a 10 years old "tip of the day"!) -- Amaury Forgeot d'Arc
thanks. ughh! 10 years old. oh boy. Garyc --- On Sat, 10/3/09, Amaury Forgeot d'Arc <amauryfa@gmail.com> wrote:
From: Amaury Forgeot d'Arc <amauryfa@gmail.com> Subject: Re: [Twisted-Python] XML parsing on twisted To: "Twisted general discussion" <twisted-python@twistedmatrix.com> Date: Saturday, October 3, 2009, 5:42 PM Hi,
Hello,
I went to use the SAX library to perform parsing. However I hit an unusual problem.
Its having a problem parsing a token that has a '&' it just crashes. It certainly woke me up when I witnessed this.
<books> Jim & Nancy </books>
are passed to the ContentHandler class. When characters(self,chars) member gets called I perform self.book+=chars to reassemble the string.
I dump out the self.book string as its being assembled. If I replace the '&' character with "and"
2009/10/4 gary clark <burslem2001@yahoo.com>: then its Ok. Of course I dont want to have to replace '&' with 'and'.
Not good. So has anybody else seen this problem. I'm
assuming it thinks its a reference and becomes confused when I attempt to add a reference.
Much appreciated,
the & character is a special character in XML. You are parsing an invalid XML string. This page says it well: http://www.devx.com/tips/Tip/14068 (a 10 years old "tip of the day"!)
-- Amaury Forgeot d'Arc
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
participants (2)
-
Amaury Forgeot d'Arc
-
gary clark