É frequentemente usado ao emitir RSS e XML e não é exatamente o mesmo que htmlencode
princípio:
| Personagem | Convertido em |
| " | |
| ' | ' |
| & | & |
| < | < |
| > | > |
Código
<%
Função xmlencode (byval stext)
stext = substituir (stext, "&", "&")
stext = substituir (stext, "<", "<")
stext = substituir (stext, ">", ">")
stext = substituir (stext, "'", "" ")
stext = substituir (stext, "" "", "")
Xmlencode = stext
Função final
%>
Outro:
<%
Função pública XMLencode (BYVAL STRTEXT como string) como string
Dim arychars () como variante
arychars = matriz (38, 60, 62, 34, 61, 39)
Dim i como inteiro
Para i = 0 para ubound (arychars)
strText = substituir (strText, chr (arychars (i)), "&#" & arychars (i) & ";")
Próximo
Xmlencode = strText
Função final
%>