Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: array data to json

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


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,

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-19 22:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found