Summary:

Although you can attack a city and wear it down with ranged units, you cannot capture the city with a ranged unit; you must move a melee unit into the city to take it. Similarly, air units and ranged water units cannot capture a city, though they can wear its defenses down to nothing.