in reply to & and XML::Simple

Its by design, as "&" is just the xml way to write "&"

The way you're using XML::Simple it is not giving you "raw" xml and thats a good thing

The way you're passing on what XML::Simple gives is your problem, the other end is expecting xml, but you're not giving it xml, you forgot to escape/encode/xmlify the data you're sending

Replies are listed 'Best First'.
Re^2: & and XML::Simple
by Anonymous Monk on Jun 08, 2017 at 00:39 UTC
    I forgot code tags :) "&" is the xml way to write "&", its how xml encoded/escapes "&"
      ok. So I just added this bit to "XML-ify" what i'm sending:
      $URLFix = '&'; $parsedPayload->{results_link} =~ s/&/$URLFix/g;
      And that would be "The correct way to fix it"?
        The "correct way to fix it" is to use an XML building module that automatically escapes things for you.
        use strict; use warnings; use XML::Simple qw( :strict ); my $xml = '<foo><bar>blah&amp;blah</bar></foo>'; my @opts = (KeepRoot=>1, KeyAttr=>[]); my $data = XMLin($xml, ForceArray=>1, @opts); use Data::Dump; dd($data); print(XMLout($data, @opts));
        Output:
        { foo => [{ bar => ["blah&blah"] }] } <foo> <bar>blah&amp;blah</bar> </foo>
        Note that the ampersand is unescaped in the first output line, then escaped again in the XML.

        Also, don't use XML::Simple. Someone want to suggest a better module?

        No.