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.

<?xml version="1.0"?> <!DOCTYPE BlastOutput PUBLIC "-//NCBI//NCBI BlastOutput/EN" "http://ww +w.ncbi.nlm.nih.gov/dtd/NCBI_BlastOutput.dtd"> <BlastOutput> <BlastOutput_program>blastn</BlastOutput_program> <BlastOutput_version>BLASTN 2.2.29+</BlastOutput_version> <BlastOutput_reference>Stephen F. Altschul, Thomas L. Madden, Alejan +dro A. Sch&amp;auml;ffer, Jinghui Zhang, Zheng Zhang, Webb Miller, an +d David J. Lipman (1997), &quot;Gapped BLAST and PSI-BLAST: a new gen +eration of protein database search programs&quot;, Nucleic Acids Res. + 25:3389-3402.</BlastOutput_reference> <BlastOutput_db>nr</BlastOutput_db> <BlastOutput_query-ID>96197</BlastOutput_query-ID> <BlastOutput_query-def>No definition line</BlastOutput_query-def> <BlastOutput_query-len>16</BlastOutput_query-len> <BlastOutput_param> <Parameters> <Parameters_expect>1000</Parameters_expect> <Parameters_sc-match>1</Parameters_sc-match> <Parameters_sc-mismatch>-3</Parameters_sc-mismatch> <Parameters_gap-open>5</Parameters_gap-open> <Parameters_gap-extend>2</Parameters_gap-extend> <Parameters_filter>F</Parameters_filter> </Parameters> </BlastOutput_param> <BlastOutput_iterations> <Iteration> <Iteration_iter-num>1</Iteration_iter-num> <Iteration_query-ID>96197</Iteration_query-ID> <Iteration_query-def>No definition line</Iteration_query-def> <Iteration_query-len>16</Iteration_query-len> <Iteration_hits> <Hit> <Hit_num>1</Hit_num> <Hit_id>gi|410994849|gb|CP003920.1|</Hit_id> <Hit_def>Uncultured Sulfuricurvum sp. RIFRC-1, complete genome</Hit_ +def> <Hit_accession>CP003920</Hit_accession> <Hit_len>2358861</Hit_len> <Hit_hsps> <Hsp> <Hsp_num>1</Hsp_num> <Hsp_bit-score>32.2105</Hsp_bit-score> <Hsp_score>16</Hsp_score> <Hsp_evalue>21.4857</Hsp_evalue> <Hsp_query-from>1</Hsp_query-from> <Hsp_query-to>16</Hsp_query-to> <Hsp_hit-from>1544571</Hsp_hit-from> <Hsp_hit-to>1544556</Hsp_hit-to> <Hsp_query-frame>1</Hsp_query-frame> <Hsp_hit-frame>-1</Hsp_hit-frame> <Hsp_identity>16</Hsp_identity> <Hsp_positive>16</Hsp_positive> <Hsp_gaps>0</Hsp_gaps> <Hsp_align-len>16</Hsp_align-len> <Hsp_qseq>ATTCGATCGGTTACTC</Hsp_qseq> <Hsp_hseq>ATTCGATCGGTTACTC</Hsp_hseq> <Hsp_midline>||||||||||||||||</Hsp_midline> </Hsp> </Hit_hsps> </Hit> <Hit> <Hit_num>2</Hit_num> <Hit_id>gi|119500557|ref|XM_001267035.1|</Hit_id> <Hit_def>Neosartorya fischeri NRRL 181 conserved hypothetical protei +n (NFIA_106270) partial mRNA</Hit_def> <Hit_accession>XM_001267035</Hit_accession> <Hit_len>1188</Hit_len> <Hit_hsps> <Hsp> <Hsp_num>1</Hsp_num> <Hsp_bit-score>32.2105</Hsp_bit-score> <Hsp_score>16</Hsp_score> <Hsp_evalue>21.4857</Hsp_evalue> <Hsp_query-from>1</Hsp_query-from> <Hsp_query-to>16</Hsp_query-to> <Hsp_hit-from>384</Hsp_hit-from> <Hsp_hit-to>399</Hsp_hit-to> <Hsp_query-frame>1</Hsp_query-frame> <Hsp_hit-frame>1</Hsp_hit-frame> <Hsp_identity>16</Hsp_identity> <Hsp_positive>16</Hsp_positive> <Hsp_gaps>0</Hsp_gaps> <Hsp_align-len>16</Hsp_align-len> <Hsp_qseq>ATTCGATCGGTTACTC</Hsp_qseq> <Hsp_hseq>ATTCGATCGGTTACTC</Hsp_hseq> <Hsp_midline>||||||||||||||||</Hsp_midline> </Hsp> </Hit_hsps> </Hit> </Iteration_hits> <Iteration_stat> <Statistics> <Statistics_db-num>21147878</Statistics_db-num> <Statistics_db-len>2146527478</Statistics_db-len> <Statistics_hsp-len>0</Statistics_hsp-len> <Statistics_eff-space>0</Statistics_eff-space> <Statistics_kappa>0.710602795216363</Statistics_kappa> <Statistics_lambda>1.37406312246009</Statistics_lambda> <Statistics_entropy>1.30724660390929</Statistics_entropy> </Statistics> </Iteration_stat> </Iteration> </BlastOutput_iterations> </BlastOutput>

In reply to Re^4: multiple XML fields in one line by smice
in thread multiple XML fields in one line by smice

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.