2

I have two systems, one RHEL5 and one Ubuntu 10.04, and they exhibit differing behavior. I'm using perl's XML::Simple to parse the response of a call to some SaaS software. The response is:

    <xml answer="{&quot;foo&quot;: &quot;bar&quot;}" />

The ubuntu system correctly returns {"foo": "bar"}, but the RHEL5 system leaves the quoted entities in the attribute tag, and I cannot seem to find the option to change this.

Yes, the XML::Simple versions are slightly different (and I cannot change that); RHEL5: 2.14, Ubuntu: 2.18. I'd love to solve this so that the behavior is consistent.

  • You are under the misconception that you cannot install an additional up-to-date version of the XML-Simple distro. From the [Stack Overflow Perl FAQ](http://stackoverflow.com/questions/tagged/perl?sort=faq): http://stackoverflow.com/questions/102850/how-can-i-install-cpan-modules-locally-without-root-access-dynaloader-pm-line-2 http://stackoverflow.com/questions/251705/how-can-i-use-a-new-perl-module-without-install-permissions http://stackoverflow.com/questions/540640/how-can-i-install-a-cpan-module-into-a-local-directory http://stackoverflow.com/questions/2980297/how-can-i-use-cpan-as-a-non- – daxim Jan 31 '12 at 18:04
  • Actually, XML::Simple wasn't the problem, it was XML::SAX::PurePerl that was buggy. – robertlandrum Jan 31 '12 at 18:51
  • 1
    @user1180854: I guess that means the linked questions solved it for you? Please feel free to post an answer to your own question. – derobert Jan 31 '12 at 19:10
  • 1
    @derobert: Not exactly. Instead I decided to downgrade to 2.14 on Ubuntu (a local dev host) to attempt to replicate the problem. This failed to produce the problem, which led me down the path of asking what XML::Simple was using that was different. I discovered the SAX, and the information about PurePerl, and asked the system owner to make some adjustments. – robertlandrum Jan 31 '12 at 21:37

1 Answers1

3

Delete the XML::SAX::PurePerl section from the file returned by

perl -MFile::Basename -E'say dirname($ARGV[0])."/SAX/ParserDetails.ini"' "`perldoc -l XML::SAX`"

The module is awful!

  • It's slow. And I mean CRAZY slow.
  • It can't doesn't handle encodings correctly.
  • And apparently, it doesn't handle entities correctly either.

If you want the best performance from XML::Simple, make sure to use

local $XML::Simple::PREFERRED_PARSER = 'XML::Parser';

Caveat: XML::Parser doesn't handle namespaces.

Note: XML::LibXML is still 17x faster than XML::Simple with XML::Parser.

ikegami
  • 367,544
  • 15
  • 269
  • 518