Spell XP is gained off of usage, does not scale with difficulty, map difficulty, kills, or damage. There is an initial 200 xp if you use a spell of a certain category on top of the xp gained from the spell you used. For example if you used fireball you would get 236 xp the first time you used it since fireball gives 36 xp, if you used it a second time you would get 272 xp. This can be used with multiple different classes.
Example:
if you used three different spells: fireball, strikes, and thrower. this is what your xp would look like after you use it once then die
Pyro +236 xp
Elec +236 xp
Acid +254 xp
if you used these spells two times
Pyro +272 xp
Elec +272 xp
Acid +308 xp
If you are new to the game and want to level multiple different spell classes, using 1 spell on 3 different classes that give you the most xp and then dying on the highest difficulty you can do is definitely the best option for you. (boring sure but its the fastest)
the best method for leveling a single class is using 3 of the same spells and spamming them as much as you can, or using all of them and then dying in nightmare mode (or the hardest difficulty you can do, i would atleast do very hard). Or refer to the paragraph above if you want to level multiple classes.
(this chart is not finished because i do not have all of the spells yet, but as soon as i do i will update it)