A four-year-old boy was taken to hospital after being attacked by a large neighbourhood dog in Sydney's west on Sunday afternoon.

Police and rangers struggled to detain a large black and white dog who had attacked a five-year-old boy in Quakers Hill on Sunday afternoon. Credit:7 News Sydney

Emergency services were called to Jocelyn Boulevard in Quakers Hill about 1pm, where they found the boy with bite wounds to his neck.

He was treated at the scene and taken to the Children's Hospital at Westmead in a stable condition, a NSW Ambulance spokesman said.

The boy was standing on the footpath with his brother, talking to the neighbour, when the dog attacked, Acting Inspector Al John of the Riverstone Police said.