Replace cast by toXmlStr().