[Israel.pm] escaping the values of XML attributes
Shlomo Yona
shlomo at cs.haifa.ac.il
Wed Sep 22 10:17:52 PDT 2004
Hello,
When generating XML documents I face the problem of
selecting the apropriate set of quotes to use on attribute
values.
I usually use this
sub get_quotes {
my ($string) = @_;
return q{'} if $string =~ /"/;
return q{"};
}
to determine the quotes to be used (depending on the string
at hand).
problem is, my data now contains strings that have doube and
single quotes in them.
I need some escaping subroutine that I can trust to do the
right thing and escape the strings in a way supported by
standard xml parsers.
Anyone has a clue?
--
Shlomo Yona
shlomo at cs.haifa.ac.il
http://cs.haifa.ac.il/~shlomo/
More information about the Perl
mailing list