Use getAttribute to avoid KeyErrors

Signed-off-by: Daniele Ricci <daniele.athome@gmail.com>