http://www.perlmonks.org?node_id=1201470


in reply to XML::Smart - undesired decoding of special XML characters

I highly discourage this but I was curious to try it and didn't see any way around this kind of wackiness in the XML::Smart docs, and it will "work" for what you want.

use strictures; use XML::Smart; use Aspect; open my $fh, "<", "xml.xml" or die $!; my $logString = do { local $/; <$fh> }; around { my $return = $_->original->($_->args); $_->return_value( $return == 4 ? 2 : $return ); } call "XML::Smart::_data_type"; my $test = XML::Smart->new($logString); print $test->data;

Docs -> Aspect. The problem is that XML::Smart sees anything outside a very basic set of characters as binary; it's being overly formal but seems pretty correct really. So, the second you pass in any wide/utf-8 stuff, the binary switch flips. I poked around a little and didn't see a way to circumvent or configure around it.

My real advice since XML::Smart is not actively maintained would be switch to a different XML library. XML::Twig or XML::LibXML probably.