Skip to main content.
home | support | download

Back to List Archive

Re: XML2 parser error?

From: Peter Karman <karman(at)not-real.cray.com>
Date: Fri Jul 30 2004 - 15:47:54 GMT
oh wait, that isn't right. that'll encode everything like a-z0-9, etc.

better to explicitly name the chars you want encoded, though. someone 
with a clearer head than me this a.m. could list the chars that are 
truly unsafe for libxml2. if, as Keith says, 9, 10 and 13 are legit, 
than perhaps this would work better:

my $unsafe;
$unsafe .= chr for (0 .. 8, 11, 12, 14 .. 32);
$contents = "<xml>\n" .
HTML::Entities::encode_entities($contents,$unsafe) .
"\n</xml>";

Peter Karman wrote on 7/30/04 10:16 AM:


> my @unsafe = 0 .. 32;	# or whatever ascii you DON'T want encoded
> my $unsafe;
> $unsafe .= chr for @unsafe;
> 
> $contents = "<xml>\n" . HTML::Entities::encode_entities($contents, 
> "[^$unsafe]") .
> "\n</xml>";
> 


-- 
Peter Karman - Software Publications Engineer - Cray Inc
phone: 651-605-9009 - mailto:karman@cray.com
Received on Fri Jul 30 08:48:12 2004