... could someone explain what is happening, and why?

Its easier to start from the beginning :) you've got too much code in the question, trim it down to absolute minimum, use Data::Dump::dd for generating sample input, and for verifying the encoding of data, deal with just 3 strings, input, wanted output, actual output, and explain what you don't like about actual output

I don't see no problems here, or need to encode/decode anything myself (perlunitut: Unicode in Perl) since libxml knows about encodings

#!/usr/bin/perl -- use warnings; use strict; use XML::LibXML; my $orig = "<?xml version='1.0' encoding=\"ISO-8859-1\" standalone=\"y +es\"?><tag string=\"s&#195;&#188;&#195;&#159;e\" />"; my $dom = XML::LibXML->new(qw/ recover 2 /)->load_xml( string => $ori +g ); dd( $orig ); dd( "$dom" ); dd( $dom->findvalue( q{//*/@string } ) ); printf "%v02x\n", $dom->findvalue( q{//*/@string } ); dd( map { ord $_ } split //, $dom->findvalue( q{//*/@string } ) ); __END__ "<?xml version='1.0' encoding=\"ISO-8859-1\" standalone=\"yes\"?><tag +string=\"s&#195;&#188;&#195;&#159;e\" />" "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"yes\"?>\n< +tag string=\"s\xC3\xBC\xC3\x9Fe\"/>\n" "s\xC3\xBC\xC3\x9Fe" 73.c3.bc.c3.9f.65 (115, 195, 188, 195, 159, 101)

In reply to Re: Encode double encoding? by Anonymous Monk
in thread Encode double encoding? by DrkShadow

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.