Created
June 10, 2009 09:16
-
-
Save lestrrat/127112 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use utf8; | |
use XML::LibXML; | |
use Encode; | |
my $xml = encode('euc-jp', <<EOXML); | |
<?xml version="1.0" encoding="euc-jp"?> | |
<foo> | |
<bar attr="日本語">日本語のbar</bar> | |
</foo> | |
EOXML | |
print "XML -> $xml\n"; | |
my $dom = XML::LibXML->new->parse_string($xml); | |
my $xpath = encode('euc-jp', '/foo/bar[@attr="日本語"]/text()'); | |
print "XPath -> $xpath\n"; | |
my @nodes = $dom->findnodes($xpath); | |
use Data::Dumper; | |
print Dumper(@nodes); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment