This is my view on XP: Experience is awarded for overcoming a challenge, not for killing things. This is why XP is awarded for traps (whether or not it's disabled, XP is awarded for the trap as long as it's encountered) and non-combat encounters.
Therefore, in the two situations provided in...