Take a look at the -o option which shows only the matching part. However, if you grep only for the pattern "XY" it will show you only "XY", so that you have to elaborate a regular expression to match the entire words containing "XY".
Edit: druuna beated me. Just a note anyway: if the word can contain any character, like numbers or special characters, I would end-up with something like this:
grep -Eno '[^[:space:]]*XY[^[:space:]]*' file
to match anything but the space