awk - sed / reading from a data file and doing algebraic operations

Hi everyone,
I am trying to write a bash script which reads a data file and does some algebraic operations.
here is the structure of data.xml file that I have;

1 <data>
2 .
3 .
4 .
5 </data>
6 <data>
7 .
8 .
9 .
10</data>
etc.

Each data block contains same number of lines (say for example 5 lines)

Q1. How can I find the total number of data blocks in a given data file?

Q2. How can I assign that number to a variable which is going to be used on further lines?

thanks.

It would help immensely if you were to post 10-15 lines from your real data file.
What you posted is going to have us guessing - poorly.

You could do:

BLOCKS=`grep '<data>' infile | wc -l`

or

BLOCKS=`awk '/<data>/{L++}END{print L}' infile`

thanks Chubler, that will do.
Could you please tell me what is the function of the following part?
| wc -l

 
wc -l 

is used to count the number of lines.

man page of wc Man Page for wc (opensolaris Section 1) - The UNIX and Linux Forums