As far as I can tell from the code you posted, there is absolutely nothing wrong.
However, considering that the XML you provided in only an extract, and does not show the </questions>
closing tag, I suspect there may be a q
element somewhere with a missing answer
attribute.