A Chinese man attacked at least 20 young children at a Beijing primary school with a hammer on Tuesday, state television reported, in a rare act of violence in the capital.