in reply to UTF8 issue with XML::XPath

I would try to set the output file to UTF-8 mode, at least that's how I did it with XML::LibXML:

my $outfile = "config.xml"; open my $xml, ">:utf8", $outfile or die "Couldn't create '$outfile': $!"; # Alternatively: # binmode $xml, 'utf8'; print {$xml} $xp->find('/conf')->get_node(1)->toString; close $xml;

Replies are listed 'Best First'.
Re^2: UTF8 issue with XML::XPath
by eserte (Deacon) on Mar 05, 2008 at 19:18 UTC
    If you need to specify the encoding on an XML file, then the XML parser is broken.

    The XML encoding is specified in the XML file itself, and the XML parser MUST parse the encoding and act accordingly.

    Seems that I was reading too fast ... it's not about parsing an XML file, but about writing an XML fragment. And indeed, this is the right solution, one has to specify the encoding himself in this situation.