Skip Menu |

This queue is for tickets about the XML-Simple CPAN distribution.

Report information
The Basics
Id: 37147
Status: resolved
Priority: 0/
Queue: XML-Simple

People
Owner: Nobody in particular
Requestors: buzz [...] exotica.org.uk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Decoding entities
When creating XML i notice by default XML::Simple will encode < > & etc. It would also make sense I would have thought to decode in the same way when XML is given as input. Otherwise an application would have to "loop" through the hashref to decode everything. Or have I missed a reason this is by design ?
XML::Simple doesn't directly read XML, it relies on an underlying parser module (either XML::Parser or an XML::SAX module). As far as I'm aware, all the parser modules *do* decode entities in the way you suggest. Also, the XML::Simple test suite checks this functionality. Can you give some sample code where this isn't working for you?
From: buzz [...] exotica.org.uk
On Thu Jun 26 19:07:41 2008, GRANTM wrote: Show quoted text
> XML::Simple doesn't directly read XML, it relies on an underlying
parser Show quoted text
> module (either XML::Parser or an XML::SAX module). As far as I'm
aware, Show quoted text
> all the parser modules *do* decode entities in the way you suggest. > Also, the XML::Simple test suite checks this functionality. > > Can you give some sample code where this isn't working for you?
I'm sorry that I wasn't more specific. It was something I ran into a few days ago, and I couldn't remember the exact case. I just researched it again now and it only happens with numeric entities in attributes. I ran into the problem when using the XML::Simple with the MediaWiki API. some code: use warnings; use strict; use XML::Simple qw(:strict); use Data::Dumper; my $ref = XML::Simple->new()->XMLin(' <myxml><notworking values="&#060;" /><working>&#060;</working></myxml> ', ForceArray => 0, KeyAttr => [ ] ); print Dumper $ref; produces $VAR1 = { 'working' => '<', 'notworking' => { 'values' => '&#060;' } };
Subject: Re: [rt.cpan.org #37147] Decoding entities
Date: Fri, 27 Jun 2008 13:45:58 +1200
To: bug-XML-Simple [...] rt.cpan.org
From: Grant McLean <grant [...] mclean.net.nz>
On Thu, 2008-06-26 at 21:35 -0400, Jools Smyth via RT wrote: Show quoted text
> I'm sorry that I wasn't more specific. It was something I ran into a > few days ago, and I couldn't remember the exact case. I just > researched it again now and it only happens with numeric entities in > attributes. I ran into the problem when using the XML::Simple with the > MediaWiki API.
I suspect that indicates you're using an old version of XML::SAX::PurePerl. There was a bug in that area that was fixed in version 0.15 of XML::SAX. But, if you have SAX installed, you probably don't want to use the PurePerl parser anyway since it is very slow. I'd recommend installing either XML::SAX::Expat or XML::SAX::ExpatXS. Either of these will be both faster and less buggy. Cheers Grant
From: buzz [...] exotica.org.uk
Show quoted text
> I suspect that indicates you're using an old version of > XML::SAX::PurePerl. There was a bug in that area that was fixed in > version 0.15 of XML::SAX.
I installed from Ubuntu Hardy. It has libxml-sax-perl 0.16. So perhaps this bug is not yet fixed ? Show quoted text
> But, if you have SAX installed, you probably don't want to use the > PurePerl parser anyway since it is very slow. I'd recommend
installing Show quoted text
> either XML::SAX::Expat or XML::SAX::ExpatXS. Either of these will
be Show quoted text
> both faster and less buggy.
I've just installed ML::SAX::Expat and the problem still occurs. do I need to force it to use the correct module ? Best Regards Jools
Subject: Re: [rt.cpan.org #37147] Decoding entities
Date: Fri, 27 Jun 2008 14:16:03 +1200
To: bug-XML-Simple [...] rt.cpan.org
From: Grant McLean <grant [...] mclean.net.nz>
On Thu, 2008-06-26 at 21:57 -0400, Jools Smyth via RT wrote: Show quoted text
> Queue: XML-Simple > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=37147 > >
> > I suspect that indicates you're using an old version of > > XML::SAX::PurePerl. There was a bug in that area that was fixed in > > version 0.15 of XML::SAX.
> > I installed from Ubuntu Hardy. It has libxml-sax-perl 0.16. So perhaps > this bug is not yet fixed ?
That maybe the case. The maintainer of XML::SAX (me) is very slack. Show quoted text
> > But, if you have SAX installed, you probably don't want to use the > > PurePerl parser anyway since it is very slow. I'd recommend
> installing
> > either XML::SAX::Expat or XML::SAX::ExpatXS. Either of these will
> be
> > both faster and less buggy.
> > I've just installed ML::SAX::Expat and the problem still occurs. do I > need to force it to use the correct module ?
On Debian/Ubuntu, the default SAX parser is the last one listed in: /etc/perl/XML/SAX/ParserDetails.ini For testing, you can also do something like: XML_SIMPLE_PREFERRED_PARSER=XML::SAX::Expat ./test.pl Cheers Grant
From: buzz [...] exotica.org.uk
the default is the pure Perl one (yours). Could be a problem since this setup is quite common. Thanks for the support.
This problem has been resolved in the recent 0.96 release of XML::SAX