in reply to Re: emdash problems with XML::Simple
in thread emdash problems with XML::Simple

Wow! That got rid of my longtime error. I never would have thought of that in a million years. I thought XML::Simple always used XML::Parser.

It still does something I don't expect thought... 'table'=>undef is in the Dumper printout. Why isn't it reading it properly?

Replies are listed 'Best First'.
Re^3: emdash problems with XML::Simple
by ikegami (Patriarch) on Aug 26, 2010 at 21:45 UTC

    "XML::Simple will default to using a SAX parser if one is available or XML::Parser if SAX is not available."

    You probably ended up using the PurePerl SAX parser which is/was buggy when it came to encodings. XML::Parser is by far the fastest existing backend for XML::Simple, according to my benchmarks a year ago.

    XML::Simple removes the root by default.

    my $tree = { table => {} }; $tree->{table} = $xml->XMLin($fileName, ForceArray => ['map'], KeyAttr => [] ) ->{table};
    should be
    my $tree = $xml->XMLin($fileName, ForceArray => [qw( map )], KeyAttr => {}, KeepRoot => 1, );

      Makes sense. Except, if Parser is so much better than SAX why is Simple still using SAX as a default...

        I said faster, not better. One downside of XML::Parser is that XML::Simple doesn't support namespaces when it parses using it. I don't know if there's any other differences.