Thanks for the answers. Half way there. If I get the string my self with getData on DOM::Node, it looks great, but I still get Jibberish when printing the string XML::DOM produces.

xml:

<?xml version="1.0" encoding="utf-8"?> <Name>IssuéTést</Name>

code:

#!/usr/bin/perl -w use XML::DOM; use Encode; use open OUT => ":utf8"; use open ":std"; my $XmlParserObj = XML::DOM::Parser->new(); open(IN,"<:utf8","in.xml"); my @in = <IN>; my $inStr = join("",@in); #$inStr = encode("utf8",$inStr); # redundant if I use <:utf8 in open #$inStr = decode("utf8",$inStr); # make all tested strings get "?" ins +tead of latin chars my $doc = $XmlParserObj->parse($inStr); my $value = $doc->getElementsByTagName("Name")->item(0)->getChildNodes +()->item(0)->getData(); my $str = $doc->toString(); #binmode(STDOUT,":utf8"); # redundant print "is input utf8 ? ",Encode::is_utf8($inStr),"\n"; print "Input:\n".$inStr; print "is value utf8 ? ",Encode::is_utf8($value),"\n"; print "Value: ".$value."\n"; print "is output utf8 ? ",Encode::is_utf8($str),"\n"; print "Output:\n".$str; exit(0);

output:

is input utf8 ? 1 Input: <?xml version="1.0" encoding="utf-8"?> <Name>IssuéTést</Name> is value utf8 ? 1 Value: IssuéTést is output utf8 ? 1 Output: <?xml version="1.0" encoding="utf-8"?> <Name>Issu&#14932;st</Name>

Thanks again


In reply to Re^2: error parsing utf8 chars using XML DOM parser by avih
in thread error parsing utf8 chars using XML DOM parser by avih

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.