I need to do exactly the opposite of Replacing a & in XML correctly?.

This is because I want to make human-readable some XML that I get from a log. Thus, I'd like to use xmllint --format, but it complains about how "&","<", ">" and the like are encoded.

I am going to do this on MacOS and perl is available.


As you've mentioned perl, XML::Entities will do what you want. Example:

 use XML::Entities;
 $a = "Tom &amp; Jerry &copy; Warner Bros&period;";
 $b = XML::Entities::decode('all', $a);

$b Will be the string "Tom & Jerry © Warner Bros."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.