PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → [WM22] Problem reading XMLs in iOS
[WM22] Problem reading XMLs in iOS
Iniciado por guest, 10,jul. 2017 22:27 - 5 respuestas
Publicado el 10,julio 2017 - 22:27
Good afternoon

I have the following problem, I use XMLs in WebServices in WinDev Mobile 22, Android work well because there the project was developed first, then the same content was passed to an iOS project, there is no compilation error, but the reading of XMLs does not work.

It works well in the iOS emulator but not in the device, debugging with infos it could be noticed that it does not enter the for each.

My code is as follows:

---------------------------------------------------------------------------

sResultado is string = Login(EDT_EMP_CLAVE,EDT_EMP_PASSWORD,0)

ResXML is xmlDocument
ResXML = XMLOpen(sResultado,fromString)
nResultado is int = StringCount(sResultado,"<DatosLogin>",IgnoreCase + WholeWord)

nCLI_NUM_CTRL is int
sCLI_NOMBRE is string
sResultadoBoolean is string
DatosLogin is xmlNode

FOR EACH DatosLogin OF ResXML
Info(DatosLogin)
FOR i = 1 _TO_ nResultado
Info(DatosLogin.DatosLogin.Resultado)
Info(DatosLogin.DatosLogin.CLI_NUM_CTRL)
Info(DatosLogin.DatosLogin.CLI_NOMBRE)

sResultadoBoolean = DatosLogin.DatosLogin.Resultado
nCLI_NUM_CTRL = DatosLogin.DatosLogin.CLI_NUM_CTRL
sCLI_NOMBRE = DatosLogin.DatosLogin.CLI_NOMBRE
END
END
Info(sResultadoBoolean)
IF sResultadoBoolean ~= "TRUE" THEN
...

------------------------------------------------------------------------

As it does not enter the cycle, the variable is always false
Does anyone have a solution to this?

Thanks in advance
Publicado el 10,julio 2017 - 22:55
Hi David,

your problem is not about XML, it's about the type of stirngs, if I'm not mistaken.
Under IOS, a string, by default, is a UTF 8 unicode thingy, which is NOT what has been sent by your webservice.

So as usual, the solution is to change the encoding with a utftounicode to equivalent function AFTER receiving it, but BEFORE processing it with the XML functions.

Best regards
Publicado el 10,julio 2017 - 23:40
Hi Fabrice, thanks for answer.

in the WebService I have this lines

-----------------------------------------------------------------------------------------

sXMLInfo = XMLBuildString("Login",XMLDocumentDefault,XMLEncodingIso8859_1)
XMLClose("Login")
RESULT sXMLInfo

-----------------------------------------------------------------------------------------

you say i need to change, in this case Iso8859_1 to UTF8 ?
in that case, I tried changed that line directly in the webservices for this line

-----------------------------------------------------------------------------------------

sXMLInfo = XMLBuildString("Login",XMLDocumentDefault,XMLEncodingUTF8)

-----------------------------------------------------------------------------------------

but it doesn´t work too.
Publicado el 11,julio 2017 - 02:41
Hi

What's the declaration of sXMLInfo or you may try out as below

sXMLinfo =UTF8ToString(XMLBuildString("Login",XMLDocumentDefault,XMLEncodingUTF8)
, charsetAnsi)

// if sXMLInfo is string

info(sXMLInfo) // to see it's ok

HTH

King
Publicado el 11,julio 2017 - 14:42
Hi David,

no, I did NOT say to change ANYTHING in the webservice...

I said to change something in the IOS code. And I repeat:

So as usual, the solution is to change the encoding with a utftounicode to equivalent function AFTER receiving it, but BEFORE processing it with the XML functions.

Best regards
Publicado el 11,julio 2017 - 19:38
We already solved it.

Thanks !