Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: multiple XML fields in one line

by poj (Priest)
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});

with

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

poj


Comment on Re: multiple XML fields in one line
Select or Download Code
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 blastHit.pl 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.
      poj

        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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (13)
As of 2014-09-30 13:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (369 votes), past polls