#! /usr/bin/perl -w use strict; use warnings; use CGI; use Data::Dumper; use CGI::Carp qw(fatalsToBrowser); use lib ('./perllib'); use XML::Simple; use utf8; my $file = './test.xml'; my $content = get_file($file); my $html = (); my $cgi = CGI->new(); print $cgi->header(-type => 'text/html'); my $jobs_h = XMLin($content); print Dumper($jobs_h); my $jobtitle = $cgi->escapeHTML($jobs_h->{content}); $jobtitle =~ s/([\x{80}-\x{FFFF}])/'&#' . ord($1) . ';'/gse; print $jobtitle; sub get_file{ my ($file) = @_; my $cont = ''; { local $/; open(DAT,"<$file") or die $!; $cont = ; close DAT; } return $cont; }