This will be a brief guide going through the basics of training your hero (mainly your attack hero), and gaining him more experience to get him to a high level. I will only go through the reasonably well known methods, and one or two other methods that I've heard off from other people, or came up with myself.
1. Purchasable items -
Such as On Wars, increase your hero's xp by either 100,000 or 100% of your hero's current level cap (whichever's greater). Then there are Epitome's which increase hero xp by 10,000 or 30% of your hero's current level cap. And finally, and most useless of all, the Anabasis, giving you only 1,000 xp or 8% of your hero's current level cap.
2. Sending heros with ballistas at level 5 NPCs -
This can be an efficient way of training ANY hero, politics, attack, or intelligence. You can send your hero at the same NPC every hour, and he will gain the same 93K experience from each attack. Any NPCs defences and army only take 1 hour to fully regenerate, for all resources inside an NPC to regenerate it takes 8 hours.
To make best use of this method, it's a good idea to have the correct technology level combination. Refer to this thread for all the details:
I've heard a few people in my alliance and I think here on the forums saying that sending 2000 warriors with your lvl5 NPC attacks greatly increases the experience you gain (as much as twice the xp maybe). My guess is because the warriors march well ahead of the ballistas in battle and kill enemy traps.
This method's fine if you don't mind losing 2000 warriors on every NPC raid. It may seem a small loss, but adds up very fast if you do it every time. You would lose 100K warriors farming 50 lvl5 NPCs that way. I don't think it's worth it, but worth mentioning.
3. Attacking NPCs lvl6 and above, mostly lvl 10s -
Personally I see NPCs between lvl6 and lvl9 a waste of space and time to farm, so I'll focus on level10s. Level 10 NPCs give a huge amount of experience when attacked (1.8 million xp), and huge amount of resource (19 million food plus 600K lumber/iron/stone).
There are many methods people use to farm lvl10 NPCs with, however the most important thing probably is NOT to upgrade your compass to level 10. With compass level 10, a hero of about 250 attack is required to bring losses down to as much as a hero of 150 attack can achieve when your compass is at level 9. Upgrading to lvl10 compass can vastly slow down your game progress, so don't do it until much later in the game. Once your heros have a very high attack, it seems compass lvl10 in fact reduces losses.
If you've upgraded to lvl10 compass, it's not the end. There are still ways to exploit lvl10 NPCs for the hero experience they give. Every time an NPC is hit, it instantly regenerates 10% of it's army and defences. This can be put to good use.
Firstly you send your main "spearhead" attack, which will take down the 400K warriors and defences inside the lvl10 NPC. Then you repeatedly follow in with reasonably large archer waves (50K archers / 25K warriors), using your lower attack heros for the attacks. This will gain you about 300K hero xp a hit from what I remember seeing.
Obviously the more archers you send on the attacks after the spearhead wave, the lower your losses will be.
4. PvP battles -
It's worth mentioning that player vs player battles also raise your hero's experience, however, PvP battles is a huge topic. This is a brief guide so I won't cover it.
NOTE: Every army unit killed in battle, whether it's yours or the enemy's gives your hero and his a certain amount of experience. Each different type of unit, such as archers, or warriors, gives different amounts of experience to your hero. From what I remember, I think every enemy unit killed in battle gains your hero twice the experience than that of any units killed of your own. There was a post or thread on this somewhere, and I'll try to find it and post it here.
If you have anything to add pls do, or correct me if I screwed something up.