Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^5: array data to json

by choroba (Cardinal)
on Jul 05, 2017 at 10:48 UTC ( [id://1194228]=note: print w/replies, xml ) Need Help??


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

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,

Replies are listed 'Best First'.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1194228]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-23 06:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found