Use getAttribute instead of getNamedItem.