in reply to array data to json

About the newlines and chomp, you should probably should be trimming.
sub trim(_) { $_[0] =~ s/^\s+|\s++\z//rg } my $severity = trim $xp->find('./severity', $node); my $remedyqueue_xpath = "..."; my $remedyqueue = [ map trim, $xp->find($remedyqueue_xpath)->get_nodelist() ];