There are 5 ways to earn xp in Clash of Clans.
1. Upgrade : Upgrade your defence. You can earn lots pf xp by upgrade.
2. Destroy Townhall : If you destroy townhall you can get some xp too.
3. Complete Achievements : You can also get xp if you complete achievements.
4. Remove Obstacles : You can get some xp if you remove obstacles (trees, rocks, bushes).
5. Donate : This is one of the fastest way .
You can also get xp if you donate troops.
You can join other clans and donate troops to earn xp.