List Info

Thread: Perl XML.




Perl XML.
user name
2007-05-02 06:24:46
Hello ,
       ; The XML Parser doesn't seem to parse some unicode values.I used Unicode:String module to see if XML::Parser will work properly but it doesn't.
The following code will make it clear:
my $u='<test>69125 LYON ST EXUPĂY AEROPORT</test>';
#my $u = Unicode::String->new($t)->utf8;

import XML::parser; import XML::Parser::Grove;
my $xml = XML::Parser->new(Style => 'grove');
my $xmlConfig;
eval
   {
   $xmlConfig = $xml->parse($u);
   };
if ($)
   {
   die "Could not parse at ".$;
   }

here inside <test&gt; tag if I put characters like &,<,*etc. it fails.Please help.


--
Regards
Karthik
Re: Perl XML.
user name
2007-05-02 08:07:00
On Wed, 2007-05-02 at 16:54 +0530, Karthik Ramaswamy wrote:
> Hello ,
>         The XML Parser doesn't seem to parse some
unicode values.I
> used Unicode:String module to see if XML::Parser will
work properly
> but it doesn't.
> The following code will make it clear:
> my $u='<test>69125 LYON ST EXUPÃY
AEROPORT</test>'; 
> #my $u = Unicode::String->new($t)->utf8;
> 
> import XML::parser; import XML::Parser::Grove;
> my $xml = XML::Parser->new(Style => 'grove');
> my $xmlConfig;
> eval
>    {
>    $xmlConfig = $xml->parse($u); 
>    };
> if ($)
>    {
>    die "Could not parse at ".$;
>    }
> 
> here inside <test> tag if I put characters like
&,<,*etc. it
> fails.Please help.

Well after fixing your code so it will actually compile
(ITYM 'use'
instead of 'import' and 'XML::Parser' instead of
'XML::parser') - it
works as exactly as I would expect.

If you have a literal '<' or '&' you will of course
get the error:

  not well-formed (invalid token) at line 1, column 8, byte
8 at ...

which is correct because per the XML spec these need to be
represented
by the entities '&lt;' and '&amp;' respectively -
otherwise the XML is
indeed not well formed.

/J
_______________________________________________
Perl-XML mailing list
Perl-XMLlistserv.ActiveState.com
To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )