You're crossing streams. Why would you give someone XP for acting selflessly? Gold for XP is intended to incentivize certain behaviors, specifically amoral antiheroic behavior. If you want to give out XP for being a Big Damn Hero, you're incentivizing a different and often conflicting set of behaviors. Generally, you should pick the one that works best in your game. If it's go for gold, then yes, they'll miss out. They can certainly act in heroic ways, but the world won't necessarily reward them for it.
If you want to reward more heroic actions, then plot or milestone-based rewards might be a better approach. The PCs get XP for saving the prince from the dragon, instead of for the dragon's hoard. Roleplaying rewards or the like can be treated as training multipliers, like in the 1e DMG.
I've just seen it pointed out as a flaw in gold for XP since, obviously, any good roleplaying game should care about the players playing their characters in a good way. So if a character is Lawful Good and doing Lawful Good things, isn't that punishing? Or put another way, is there no room for a LG character in such a game?
So I was wondering if people actually stick to this in practice, or if they just bite the bullet and play it as is, or if there's another way of looking at it from their perspective that justifies this kind of thing.
There's nothing stopping a lawful good character from doing lawful good things, when using a gold for XP system. There's just no mechanical incentive to encourage that kind of behavior. It's a philosophical aside, but I'd argue that makes the good actions count for more, because they're done without the expectation of a reward.
The XP system doesn't restrict what actions are possible. In fact, most roleplaying will take place because of things external to the XP system. Players will play their characters, negotiate, kick open doors, and on because they're fun and interesting ways to engage with the imagined world. What the XP system really does is
require the players to seek certain ends, if they want to get anywhere. In an XP for gold system, your paladin can save all the penniless orphans they want, but if you want to advance beyond first level, at some point you need to acquire some filthy lucre. So even if they do the occasional pro bono quest, it encourages players to make the main thrust of the game about acquiring treasure.
That's why I think gold for XP and plot/quest/milestone system based systems are inherently opposed. Gold for XP encourages players to take a very mercantile, what's-in-it-for-me view of the world. It's not the sole driving force, but by necessity it becomes one of the central features of the campaign. Whereas a system based on story rewards encourages the players to accomplish those goals, which are often the heroic and honorable quests of high fantasy. Again, this doesn't restrict their actions. A player can always go against the incentive structure, and satisfy their character's greed at the expense of some more noble goal. But they won't gain XP, which pushes the players to focus on those dramatic milestones most of the time, instead of simple material satisfaction.
The reason the XP rewards system is so important is because it's a constant, recurrent, push toward certain behaviors. It's carrot rather than stick, but especially in games with geometric progression, it's a very strong (tasty?) carrot. From a design standpoint, you don't need carrots for the things the players are going to anyway. Roleplaying is usually its own reward, for instance. You might offer XP to encourage shy or new players, but it's not something that's needed on an on-going basis, because it's literally the reason why most of the players are there sitting at the table. Conversely, it is useful if you want to run a campaign with a certain tone or theme. Gold for XP is good for encouraging pragmatic, rational, shades of gray antiheroes, like those in sword & sorcery, heist, or even noir stories. Milestones can be good for high fantasy, princesses and ponies, and epic quests and big bads.