Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: multiple XML fields in one line

by poj (Parson)
on Aug 07, 2014 at 17:27 UTC ( #1096671=note: print w/ replies, xml ) Need Help??

in reply to multiple XML fields in one line

Try replacing this one line in sub getMicroOrgs

push @{$ret}, $_->{Hit_def} foreach (@{$hits});


foreach (@{$hits}) { push @{$ret},join '|', $_->{Hit_def}, $_->{Hit_num}, $_->{Hit_hsps}->{Hsp}->{Hsp_identity}; }

Comment on Re: multiple XML fields in one line
Select or Download Code
Replies are listed 'Best First'.
Re^2: multiple XML fields in one line
by smice (Initiate) on Aug 08, 2014 at 16:17 UTC

    Thanks a lot for your help! Much appreciated.

    However, now the script is not working, it exits with an error message: "Not a HASH reference at line 102." It points to this line:

    push @{$ret},join '|',

    Something seems to be wrong with @{$ret}; I am educating myself on how Perl handles arrays, hashes, references and such, but in the meanwhile I'd be grateful if you would share your thoughts on this. Why it is not working now when previously it worked with the single XML field?

    Thanks a lot again!

      Can you provide a small sample of the XML file that fails.

        Yep, here is the first part, after the <Iteration_hits> there are lots of <Hit>-s, all with exactly the same structure, so I kept only the first two. The point is to search in the <Hit_def> of these <Hit>-s, but in the output we'd like to see the <Hit_num> and <Hsp_identity> attributes of the matching <Hit>-s too.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2016-05-31 21:17 GMT
Find Nodes?
    Voting Booth?