I agree on race days especially events as short as XC it is worth the go out hard and hang on approach. For a race you are typically rested, well fuelled and you don't mind hurting a bit for a result.
If you train day to day with the approach of flat out and hang on you will lose quality, increase your chacne of injury and as you have found out just run yourself out of energy. Training is about overloading, adapting and most importantly recovering to allow those previous 2 phases to sink in.
You sound like you have a handle on the moving your food around a little bit, give that a go and don't feel every run has to be a record breaker. Still do them, certainly, but don't smash yourself into the ground on a daily basis! 