Escaping characters for XML output.

Just drop the function below and make the call as shown below. You can either replace each value with a tilde (~) or HTML hex codes.
LotusScript


Function escape(Byval s$) As String
	Dim i%, result$, c$
	For i = 1 To Len(s)
		c = Mid$(s, i, 1)
		If Instr("#'%&/:;<'=´>?@[\]^`{|}~á+", c) = 0 Then
			result = result & c
		Else
			'___Replace invalid characters to HTML "%" hex codes.
			'result = result & "%" & Right$("0" & Hex(Uni(c)), 2)			
			'__Replaces invalid characters with a tilde "~"
			result = result & "~"												
		End If
	Next
	escape = result
End Function

Calling the function

Dim temp as String
temp = escape(doc.comments(0))	

Posted by fbrefere001 on Thursday October 20, 2005