CSPLIT help

I have a file with contents

<wmqi>
sdf
sdf
sdffghghhjjfh
</wmqi>
<wmqi>
gh
dfg
hhjhj
sdfsdf
g
</wmqi>
<wmqi>
dfgdf
fg
dfgfg
</wmqi>
<wmqi>
gfdfg
dfgfgfgfgf
dfgdf
</wmqi>
<wmqi>
fgfg
dfg
</wmqi>

Data between <wmqi></wmqi> is a record.
here there are 5 records. I need to do a split on 2 records(i.e create 3 files).
I learnt about csplit but unable to implement it.
Can anyone help.

---------- Post updated at 01:04 PM ---------- Previous update was at 12:07 PM ----------

any suggestions please

Hello you can use perl. works great with xml files.
xml::parser module ought to be enough.
you can search cpan.org for appropriate xml modules.
Regards.

thanks for the suggestion but i need to implement this
using unix shell script ...cant use Perl.

Something like this:

rec=0
seq=0
while read -r line
do
  case $line in
    "</wmqi>" )
       if [ $rec -eq 2 ]
       then
         rec=0
         seq=$((seq+1))
       fi ;;
    "<wmqi>" )
       rec=$((rec+1)) ;;
    *) printf "$line\n" >> file$seq.out ;;
  esac
done < infile
my $n=1;
local $/="/wmqi>\n";
while(<DATA>){
	$file = "file_".$n;
	open FH,">>$file";
	print FH $_;
	$n++ if $.%2==0;
}
__DATA__
<wmqi>
sdf
sdf
sdffghghhjjfh
</wmqi>
<wmqi>
gh
dfg
hhjhj
sdfsdf
g
</wmqi>
<wmqi>
dfgdf
fg
dfgfg
</wmqi>
<wmqi>
gfdfg
dfgfgfgfgf
dfgdf
</wmqi>
<wmqi>
fgfg
dfg
</wmqi>

thanks Scrutinizer....it works splendid ..cheers !!

Hi Shivdatta, you can further optimize like so:

while read -r line
do
  case $line in
    "</wmqi>"|"<wmqi>" )
         seq=$((seq+1)) ;;
    *)   printf "$line\n" >> file$((seq/4)).out ;;
  esac
done < infile

or like this if you do not need the precision:

while read -r line
do
  case $line in
    *wmqi">" )
         seq=$((seq+1)) ;;
    *)   printf "$line\n" >> file$((seq/4)).out ;;
  esac
done < infile