SYSXML.XMLELEMENT FUNCTION

Extensibility
Enthusiast

SYSXML.XMLELEMENT FUNCTION

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

FROM ep.department

WHERE (departmentname LIKE ANY ( '%&%','%#%'))

Result: <dept>M&S Food</dept>

Expected:  <dept>M&amp;S Food</dept>

Thanks