How can I work with XML :: XPath when the names of some elements are not in English?
I am using Strawberry Perl.
I get employees.xmland train_xml.plfrom the Internet, they work well.
But when, when I add some Chinese characters, I get the following error:
Wide character in die at D:/Strawberry/perl/site/lib/XML/XPath/Parser.pm line 189.
Query:
/employees/employee[@age="30"]/工作...
..............................^^^
Invalid query somewhere around here (I think)
How can i solve this?
employees.xml:
<?xml version="1.0" encoding="utf-8" ?>
<employees>
<employee age="30">
<name>linux</name>
<country>US</country>
<工作>教师</工作>
</employee>
<employee age="10">
<name>mac</name>
<country>US</country>
</employee>
<employee age="20">
<name>windows</name>
<country>US</country>
</employee>
</employees>
train_xml.pl:
use Encode;
use XML::XPath->new;
use utf8;
my $xp=XML::XPath->new(filename=>"employees.xml");
print $xp->findvalue('/employees/employee[@age="10"]/name'),"\n";
my $path1 = '/employees/employee[@age="30"]/工作';
print $xp->findvalue($path1),"\n";
source
share