in reply to Re^2: & and XML::Simple
in thread & and XML::Simple

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"?

Replies are listed 'Best First'.
Re^4: & and XML::Simple
by Anonymous Monk on Jun 08, 2017 at 01:57 UTC
    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?

Re^4: &amp; and XML::Simple
by Anonymous Monk on Jun 08, 2017 at 01:23 UTC
    No.