Here's the code...
Public Shared Function ApplyXMLFormatting(ByVal strInput As String) As String
' replace characters that are illegal in XML documents
strInput = Replace(strInput, "&","&" )
strInput = Replace(strInput, "'", "'")
strInput = Replace(strInput, """", """)
strInput = Replace(strInput, ">", ">")
strInput = Replace(strInput, "<", "<")
ApplyXMLFormatting = strInput
End Function