I am trying to read an XML file, and output only a select number of fields however I have ran into two issues (which I think are related) which I have utterly failed at googling.
The XML file I am working with contains a lot of non-english characts, äöåéœ etc...
When I run print Dumper($data); I get results like:
Malbec Vi\x{f1}a Domingo F Sarmiento
When I attempt to read through the XML and output specific fields, those hex symbols become questions marks:
Malbec Vi?a Domingo F Sarmiento
Any tips or at least a direction to go to for googling?
Code is as follows:
#!/usr/bin/perl -w
use strict;
use warnings;
use XML::Simple;
use Data::Dumper;
# What file to use?
my $file = "systemet.xml";
# Read in the data
my $data = XMLin($file);
# Let's get some stuff!
foreach my $status (@{$data->{artikel}}) {
print $status->{namn} . "\n";
}
Thanks for any help an开发者_运维知识库d sorry if I sound a little ignorant, it's probably because I am.
Try this
binmode(STDOUT, ":utf8");
and refer to this thread How can I output UTF-8 from Perl?
精彩评论