how to replace html line into a command line?

view full story

http://www.unix.com – hi! i'm trying to use sed for this, but i'm struggling a lot. i want to convert Code: <div class="middle" id="middle">Friday, 20 April 2012<br /> <span class="hex">728CB5</span> <br /></div> into Code: fbsetroot -solid '#728CB5' considering all information between 'id="middle">' and '<br /> <span' should be ignored or removed earlier (because it may vary), or only considering the information between '="hex">' and '</span>' (that html line above were obtained from (HowTos)