For now, it seems like wounded soldiers already gain xp also if they don't kill someone else. Just by defending. (i need to verify if they have inflicted some damages before getting wounded)
Each soldier type has a pool of XP. A wounded soldier can get XP, either because it earned it before it got wounded, or because another soldier of the same type earned it.
eg. if you enter battle with 2 Vlandian Footmen, 1 of which is wounded and one of which is combat ready... if the combat ready one goes all rambo in a battle and earns enough XP to fill the Vlandian Footman troop type's XP bar twice, you will be able to upgrade both of them. The wounded soldier doesn't get XP from any other type of troop though, only exactly the same tier and type as it. The active troop could earn the XP to upgrade himself and his wounded teammate over multiple battles, provided you don't upgrade the active one when you first get the opportunity. If you upgrade the active one, the wounded one is stuck until he recovers (or another Vlandian Recruit gets upgraded to a Vlandian Footman so you have an active one again, who can "earn XP for the wounded one"). Think of each line on your party screen as a single entity when it comes to the accumulation of XP. Only active troops can earn it, but all of that type can benefit from it potentially.
I like the idea of earning XP for getting hit, or succesfully blocking damage. Makes a lot of sense, is in theme with the "learning by doing" approach of the game, and rewards infantry for performing their role.
I like the idea
@somethinglightthat proposed for maxed out troops distributing their XP to lower troops. AFAIK that doesn't currently happen, I believe their XP vanishes into thin air and that has always bothered me a bit.
Less XP for leveling infantry is a maybe imo. Probably not necessary if the above are implemented effectively.
Not a fan of the entire army receiving distribution of the total XP value of the fight D&D style. I'd prefer to have some agency in how different types of troops in my army advance rather than their relative progress being fixed. It would probably require less XP for leveling infantry layered on so that your infantry would not constantly remain underleveled compared to the rest of your troops (due to higher mortality rate). Obviously the problem of underlevelled infantry already exists, but you can take steps to do something about it. If XP distribution is fixed, it would not be possible to compensate through your own actions - you would be at the mercy of whatever bonus the devs decided to give infantry to help them keep up, and too bad if your performance doesn't match their formula.