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

Shared XML...Removed

Replies are listed 'Best First'.
Re^5: array data to json
by choroba (Cardinal) on Jul 05, 2017 at 10:48 UTC
    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,