I suspect I'm going to sound rather like andrewwyld in parts of this post.
The golden rule of morality do unto others as you would have them do unto you has one large and obvious flaw: not everyone wants the same things you want.
We start assimilating this knowledge early in life. By 18 months old most children can understand that an adult might like different foods to the ones they like, and respond appropriately. If an adult makes yummy noises when looking at some raw broccoli and yukky noises when looking at some crackers, the kids will offer the adult broccoli even though they themselves prefer the crackers (children 4 months younger offer crackers regardless of the adults behaviour) (Repacholi and Gopnik (1997)1).
They've learned, in other words, to apply a sort of perceptual transformation to the golden rule. "I like crackers, so I will give this person crackers" becomes "I like crackers. This person feels about broccoli the way I feel about crackers, so I will give this person broccoli". We map another persons desires onto our own (when this person experiences x they feel the way I feel when I experience y); and then look at what we'd want in that position (if I were experiencing y, this is what I'd want people to do).
Lacking other information, we fall back on assuming people feel about x the way we feel about x - I'm still frequently discovering with surprise that not everyone (and not even everyone in my mental subgroup of 'people who are roughly like me') feels the same way I do about a whole range of subtle and not so subtle things.
Even where we have worked out a transform, a simple one will rarely be accurate. It's not wholly true that this person feels about x the way I feel about y. It's more that they feel about x the way I feel about y, except in situation z where they feel something between what I feel about u and w. And of course it's actually even more complicated than that.
As we come to know people, we can continually revise our transforms, getting closer and closer to an accurate picture (while, importantly, acknowledging that both their and our feelings will be changing with time as well).
With strangers we have to rely on the transforms we've accumulated for 'people like them' over the years. We've probably all been on the receiving end of a few clunkers of people applying inaccurate transforms. ("Ah a woman/oxbridge graduate/tourist/person reading a book about x. They must be interested in a/b/c"). And yet I don't see any better alternative - applying no transform at all to strangers (i.e. assuming, until we acquire further evidence, that they're exactly like us) seems likely to lead to even worse accuracy.
If I have a conclusion it's simply that it helps to be aware that this is what we're doing; that we don't (and never will) entirely understand any other person; but the more we're willing to be open to revising our transforms, the better we're likely to get at it. We're also likely to get better by exposing ourselves to a wider range of experiences and circumstances: the more experiences we have to draw on, the more likely we are to find a close match for anyone else's experience. And that actually listening to someone telling you how they feel is always going to be better than assuming you already know.
1Incidentally, when looking up the reference for this I came across a rather perceptive quote: Real empathy isn’t just about knowing that other people feel the same way you do; it’s about knowing that they don’t feel the same way and caring anyway.