lamp has asked for the wisdom of the Perl Monks concerning the following question:

Esteemed monks,

We developed an application using XML::Simple and XM::Parser. After deploying the application in QA environment, the application failed by throwing the below mentioned error

End tag mismatch ( != Value)

After debugging the issue, i found that the XML::Simple is using XML::SAX(Version 0.14) module for parsing the XML instead of XML::Parser. And also found that the XML::SAX module (version 0.14) has a bug in its handling of character entities (eg: '&') in attributes.

I have the updated the code by setting the XML::Simple preferred parser variable as 'XML::Parser' and the application is working as expected.

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

Please let me know, if there is any other way to solve this issue??

--lamp

Replies are listed 'Best First'.
Re: XML::Simple parser issue
by moritz (Cardinal) on Aug 28, 2008 at 11:58 UTC
    Please let me know, if there is any other way to solve this issue??

    Sure. Update your copy of XML::SAX to a version where this is fixed. If there is no such version, write a fix yourself.

    By the way, why do you want another solution, if yours seems perfectly simple and workable? Just the "There's more than one way to do it" principle taken to the extreme?

Re: XML::Simple parser issue
by Cody Pendant (Prior) on Aug 28, 2008 at 13:11 UTC
    I don't see the bug you're talking about here. Are you sure that's what's causing it? Not a bug in your SAX parser?

    Also, '&' is not a character entity. Maybe you typed '&' though.



    Nobody says perl looks like line-noise any more
    kids today don't know what line-noise IS ...
Re: XML::Simple parser issue
by grantm (Parson) on Aug 29, 2008 at 10:20 UTC

    XML::SAX::PurePerl is bundled with XML::SAX but you can and should install an alternate parser module to work withing the SAX framework. If you install another SAX parser such XML::SAX::Expat or XML::SAX::ExpatXS then it will become the system default SAX parser. In addition to not having the bug you're encountering, either of these modules will be significantly faster.

Re: XML::Simple parser issue
by Anonymous Monk on Aug 29, 2008 at 06:57 UTC
    I concur, upgrade XML::SAX, latest version is XML-SAX-0.96 :)