Sorry, I only sent a clip of a rather large program.
I didn't remove the preferred parser setting.
Here's a sample xml file:
<?xml version="1.0" encoding="utf-8" standalone="yes"?> <ettx ver="2"> <table id="{4fa6cd7a-f7b6-416d-8f59-3acc0eab9bdb}" name="TestFile"> <level type="V"> <map sync="Title" src="some unicode chars"/> </level> </table> </ettx>
Here's the code where the XML parsing takes place:
package ETTX; use strict; use warnings; use XML::Simple; local $XML::Simple::PREFERRED_PARSER = 'XML::Parser'; sub new(){#scalar file name my $class = shift; my $self = { ettxFile => '', ettx => {}, }; bless $self, $class; load($self,shift) if @_ ==1; return $self; }; sub load(){#scalar file name my ($self, $ettxFile) = @_; print "loading $ettxFile"; open(my $fh, '<', $ettxFile); binmode($fh); my $xml = XML::Simple->new(); $self->{ettx} = $xml->XMLin($fh, ForceArray => ['map'], KeyAttr => {}, ) ->{table}; $self->{ettxFile} = $ettxFile; 1; }
I call it from somewhere else like this:
my $ettx = ETTX->new(); $ettx->load($ettxFile);
utf8 with BOM kills it; without is fine.
In reply to Re^5: Encode throws "Wide character in subroutine entry" when using XML::Simple
by nglenn
in thread Encode throws "Wide character in subroutine entry" when using XML::Simple
by nglenn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |