SED: Extracting text between first occurance of foo in front of bar

Suppose I have a text file that contains the tags <foo> and <bar>. The text file can have unlimted occurances of <foo> and <bar> and looks somthing like this:

<foo>

Some
Text

<foo>

Some 
Text

<bar>

Some
Text

<foo>

Some
Text

There is no set amount of times <foo> occurs before or after <bar>. In this example there are two occurrences before, but there could be more or less. The only unique identifier in the file is <bar> so the logic has to be based around it. My question is how do I write a SED function that extracts the text between <bar> and the <foo> above it?

This seems the answer of this question:

http://www.unix.com/shell-programming-scripting/116920-sed-extract-xml-value.html\#post302347857

Regards