I would set the atribute using the SimpleXmlElement API, so that it handles escaping the needed chars.