Skip to main content.
home | support | download

Back to List Archive

Re: XML2 parser error?

From: Jonas Wolf <JOWOLF(at)not-real.uk.ibm.com>
Date: Mon Aug 02 2004 - 08:34:41 GMT
THanks for the tip, I'll try to make use of that. On a different note, I 
realised I should be using encode_entities_numeric instead, because 
representations like &quot; seem to annoy libxml2 as well...

Jonas




jeesh. just ignore me (in general, if you want to). this is what I meant:

my $unsafe;
$unsafe .= chr for (9, 10, 13);

$contents = "<xml>\n" .
HTML::Entities::encode_entities($contents,$unsafe) .
"\n</xml>";


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

> 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 Mon Aug 2 01:34:56 2004