Estimados me encuentro con un problema con _ especiales dentro de un XML. No puedo encontrar una forma efectiva de que _ sea reemplazados/escapados y no rompan el archivo XML.
cPassword:='ugBM08–/Y~]>'
Ejemplo:
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">'+cPassword+'</wsse:Password>
Cuando miro el XML generado la variable es reemplazada y queda asi,
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">ugBM08</wsse:Password>
deberia quedar asi
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">ugBM08–/Y~]></wsse:Password>
la cadena queda cortada por lo tanto los valores no van correctamente.
Si alguno a luchado con este problema de _ especiales?.
Por ahora estoy intentando con esto pero no ayuda,
cPassword:= strtran( cPassword, '&', "& y" )
Muchas Gracias por la ayuda que e puedan enviar.
Saludos Mariano
XML Caracteres Especiales
Re: XML Caracteres Especiales
Esto?
Regards, saludos.
Code: Select all | Expand
// C:\FWH\SAMPLES\MFERRAZ.PRG
#Include "FiveWin.ch"
FUNCTION Main()
LOCAL cPassword, cVar
cPassword := 'ugBM08–/Y~]>'
cVar := TOMA_ACENTUACION( cPassword )
? cVar
RETURN NIL
FUNCTION TOMA_ACENTUACION( cStr )
LOCAL cStrNew := "", nX, cAcentos, cLetras
cAcentos := { "&","Ë", "œ", "‹", "‡", "A", "—", "ƒ", "Æ", "Ç", " ", "µ", "…", "·", "‚", "É", "ê", "ˆ", "", "Ò", "í", "Í", "ó", "¢", "à", "ä", "å", "“", "â", "ú", "é", "", "š", "ç", "€", "ã", "Ã", "á", "Á", "à", "À", "é", "É", "ê", "Ê", "í", "Í", "ó", "Ó", "õ", "Õ", "ô", "Ô", "ú", "Ú", "ü", "Ü", "ç", "ù", "AAO", "§", "¦", "º", "ª", "€", "‡", "Ç", "ç", "'", "`", "ø", "¡", "Þ", "×", "Ø", "ÿ", "Ö", chr( 239 ) }
cLetras := { "E","E", "Y", "I", "C", "A", "U", "A", "A", "A", "A", "A", "A", "A", "E", "E", "E", "E", "E", "E", "I", "I", "O", "O", "O", "O", "O", "O", "O", "U", "U", "U", "U", "C", "C", "A", "A", "A", "A", "A", "A", "E", "E", "E", "E", "I", "I", "O", "O", "O", "O", "O", "O", "U", "U", "U", "U", "C", " ", "AAO", ".", ".", ".", ".", "C", "C", "C", "C", "" , "" , ".", "I", "I", "I", "I", "", "I", "" }
FOR nX := 1 TO LEN( cAcentos )
cStrNew := StrTran( cStr, cAcentos[nX], cLetras[nX] )
cStr := cStrNew
NEXT
Return( cStrNew )
// FIN / END
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Re: XML Caracteres Especiales
Estimado Mariano
Intenta así:
En éste link podés ver los otros
https://ascii.cl/es/codigos-html.htm
Intenta así:
Code: Select all | Expand
cPassword:= strtran( cPassword, '&', "&")
https://ascii.cl/es/codigos-html.htm
Saludos,
Adhemar C.
Adhemar C.
- Antonio Linares
- Site Admin
- Posts: 42259
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: XML Caracteres Especiales
Prueba si te funciona así:
Code: Select all | Expand
PROCEDURE Main()
LOCAL cPassword := 'ugBM08–/Y~]>'
LOCAL cEscapedPassword := EscapeXMLPassword(cPassword)
LOCAL cXMLElement := '<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">' + cEscapedPassword + '</wsse:Password>'
? "Contraseña original:", cPassword
? "Contraseña escapada:", cEscapedPassword
? "Elemento XML completo:", cXMLElement
RETURN
FUNCTION EscapeXMLPassword(cPassword)
LOCAL cResult := ""
LOCAL nLen := Len(cPassword)
LOCAL cChar
LOCAL i
FOR i := 1 TO nLen
cChar := SubStr(cPassword, i, 1)
DO CASE
CASE cChar == "&"
cResult += "&"
CASE cChar == "<"
cResult += "<"
CASE cChar == ">"
cResult += ">"
CASE cChar == '"'
cResult += """
CASE cChar == "'"
cResult += "'"
OTHERWISE
cResult += cChar
ENDCASE
NEXT
RETURN cResult
Re: XML Caracteres Especiales
Son unos genios!! muchas gracias por la ayuda estoy implementado la solución que me compartieron y verificar los resultados.
Muchas gracias son colegas de primera!!!
Abrazo Mariano.
Muchas gracias son colegas de primera!!!
Abrazo Mariano.