Unescaping XML in Logstash

Given a config file such as:

input {
  stdin {
    type => "test"
filter {
  xml {
    source => "message"
    store_xml => "false"
    xpath  => ["/MAIN/SUB/text()", "value"]
  if [value] {
    mutate {
      replace => {
        "value" => "%{[value][0]}"
output {
  elasticsearch {
    index => "test"
  stdout { codec => rubydebug }

and a sample input file of:

<MAIN><SUB>a and b</SUB></MAIN>
<MAIN><SUB>a &amp; b</SUB></MAIN>

I would expect to see the second record with the value 'a & b' in the value field but it is indexed as 'a &amp; b'. I suppose that's no surprise as the xpath could be adding blocks of XML rather than just text.

What is the best way to unescape the XML text in the conf file so that it is indexed correctly? There are five standard escapes to support plus the generic unicode escape sequence that would need to be handled. I can't find anything with XPath or the XPath functions that works.