in reply to An ampersand is not well-formed XML data?
yup, that's how you do it, but don't forget about
<, >, and "
here is one way to handle the
problem for all data:
But this is just one way# global lookup hash my %ESCAPES = ( '&' => '&', '<' => '<', '>' => '>', '"' => '"', ); # the subroutine sub xml_encode { my ($str) = @_; $str =~ s/([&<>"])/$ESCAPES{$1}/ge; return $str; } # and invoke it like $data = xml_encode($data);
Jeff
R-R-R--R-R-R--R-R-R--R-R-R--R-R-R--
L-L--L-L--L-L--L-L--L-L--L-L--L-L--
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) Re: An ampersand is not well-formed XML data?
by merlyn (Sage) on Apr 30, 2001 at 21:06 UTC | |
by mirod (Canon) on May 01, 2001 at 12:01 UTC | |
|
Re: (jeffa) Re: An ampersand is not well-formed XML data?
by donfreenut (Sexton) on Apr 30, 2001 at 21:11 UTC | |
by merlyn (Sage) on Apr 30, 2001 at 21:14 UTC | |
by donfreenut (Sexton) on Apr 30, 2001 at 21:18 UTC | |
by merlyn (Sage) on Apr 30, 2001 at 21:20 UTC |