Experience

Mechanics
See Levelling/Experience in Game Mechanics

Basically it's


 * (Gold+Iron+Wood+Food) / 2
 * For Buildings, Recruiting, Training.
 * For Raids, see below.

PvE
Total Experience gain = Base Experience + (Experience per Units Killed x Units Killed)

Base Experience

 * Equation is Base_Experience = PvE_Level x 10.
 * You get this if you Win or Lose (but for lose, you must have killed at least 1 unit)
 * PvE_Level can be determined from the PvE Chart.

PvP
Total Experience gain is Base Experience + (Experience per Units Killed x Units Killed)

Experince per Units Killed is the same as the PvE chart above.

Base Experience = Level of Opponent x 10 (win or lose, for lose, doesn't matter if you killed any units)