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

I forgot code tags :) "&" is the xml way to write "&", its how xml encoded/escapes "&"

Replies are listed 'Best First'.
Re^3: & and XML::Simple
by Jazz-jj (Novice) on Jun 08, 2017 at 00:50 UTC
    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.