Attacking a city
If a city is defeated the victorious troops will plunder it looting as many resources as they can carry.
If the defenders successfully resist, they will attempt to capture the attacking Guardian if the city has a Cage:
Capturing an enemy Guardian requires that both you and the enemy are at Palace level 10 or above.
Attacking a farming ground
Only farming grounds occupied by enemies can be attacked (farming grounds that are not occupied can be just taken, and ones that are occupied by your allies can not be touched by you). In case of an attack, the winner will occupy the farming ground, and the loser will return to their city.
If there was a Guardian present at the farming ground, the winner will attempt to capture it and bring it to their city's Cage. Again - the level 10 Palace rule applies.
Your troops can be attacked when collecting resources even when you have the Shield active, since it only protects the city. Attacking another player (also in the farming ground) will require you to lose your shield.