Question about the second mean value theorem for the integral

I have already studied the proof of the second mean value theorem for the integral, that is, for some $\xi$, $$\int^b_af(x)g(x)=f(a)\int^\xi_a g(x)dx,$$and the proof has two steps: The first step is to divide the integral into several parts $$\int^b_af(x)g(x)=\sum (f(x)-f(x_i))g(x)dx+\sum f(x_i)g(x)dx$$ but it seems hard for me to get this idea on my own. Can anyone give me some advice?

-
$\xi \in [a,b]$ right? –  Pedro Tamaroff Feb 26 '12 at 17:22
The way it's written, your equality does not hold: take $a=0$, $b=1$, $f(x)=x$, $g(x)=1$. Then your equality reads $\int_0^1x\,dx = 0\,(\xi-a)=0$. –  Martin Argerami Feb 26 '12 at 17:51
–  Aryabhata Feb 26 '12 at 18:01
@Aryabhata I understand the proof but I can't come out this proof by myself, Is there any trick or some tips? –  D-Hunter Feb 27 '12 at 3:08
@MartinArgerami I'm sorry, I have mentioned it as the second mean value theorem, that's why I omit something for brief. I just want to know how to come out this kind of proof. –  D-Hunter Feb 27 '12 at 3:10