Kevin Federline was married to Britney Spears from 2004 to 2006 .