I am adding an element of string content using the above function. What I was hoping is that the string content to be cleaned or converted to entities of characters that are not otherwise valid within XML document. But this is not happening. Any suggestions please?
SELECT sysxml.xmlelement('dept','','',departmentname) x
WHERE (departmentname LIKE ANY ( '%&%','%#%'))
Result: <dept>M&S Food</dept>
Expected: <dept>M&S Food</dept>