in reply to Re^2: array data to json
in thread array data to json

Let me repeat

> as you haven't shown the input XML, we can only guess

So, to be explicit, the input XML is required.

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^4: array data to json
by snehit.ar (Beadle) on Jul 05, 2017 at 10:04 UTC
    Shared XML...Removed
      I had to modify the XPath expression (prepend the SLB_) to match anything, otherwise it almost worked the way I showed:
      my $remedyqueue = $xp->find("./custom_attribute_list/custom_at +tribute[normalize-space(name)='SLB_RemedyQueue']/value", $node); $remedyqueue = [ map $_->string_value, $remedyqueue->get_nodelist +];

      To remove the newline from the start of the value, you need

      $remedyqueue = [ map { (my $s = $_->string_value) =~ s/\n//; $s } +$remedyqueue->get_nodelist ];

      or, in Perl 5.14 and later:

      $remedyqueue = [ map $_->string_value =~ s/\n//r, $remedyqueue->ge +t_nodelist ];

      Update: If you know you're interested in the first element of the nodeset only, you can call string_value directly on the set (see XML::XPath::NodeSet ):

      $remedyqueue = $remedyqueue->string_value =~ s/\n//r;

      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,