PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile 24 → WS_Android_iOs_ReadXml - Read Xml in Android e iOS
WS_Android_iOs_ReadXml - Read Xml in Android e iOS
Débuté par adrianoboller, 03 jan. 2015 17:49 - 1 réponse
Membre enregistré
2 962 messages
Popularité : +89 (91 votes)
Posté le 03 janvier 2015 - 17:49
Procedure WS_Android_iOs_ReadXml(XML_Retorno is string, Xml_Atributo is string )

//Exemplo de Uso:
// XML_Retorno is string = [
//<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
//xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
//xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
//<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
//xmlns:NS1="urn:act297_RtPlusSSDM-IRtPlusSSDM">
//<NS1:VerificarVersaoDeTabelasResponse xmlns:NS2="urn:act297_RtPlusSSDM">
//<NS2:TVersaoTabelas id="1" xsi:type="NS2:TVersaoTabelas">
//<datHoraMotivos xsi:type="xsd:string">2013-07-11T17:15:33</datHoraMotivos>
//<qtdMotivos xsi:type="xsd:int">3</qtdMotivos>
//<datHoraCartoes xsi:type="xsd:string">2013-07-01T12:00:00</datHoraCartoes>
//<qtdCartoes xsi:type="xsd:int">6</qtdCartoes>
//<datHoraPesquisa xsi:type="xsd:string">2013-07-10T12:14:42</datHoraPesquisa>
//<qtdPesquisa xsi:type="xsd:int">4</qtdPesquisa>
//</NS2:TVersaoTabelas>
//<return href="#1"/>
//</NS1:VerificarVersaoDeTabelasResponse>
//</SOAP-ENV:Body>
//</SOAP-ENV:Envelope>
// ]
//
// Uso da Funcao:
//arrTemp is array of strings = WS_Android_iOs_ReadXml(XML_Retorno,"NS2:TVersaoTabelas")

arrXml_TagResult is array of strings
xposicaoinicial is int = 0
Xposicaofinal is int = 0
X is int = 0
arrXml_Tag is array of strings

Inicial is int = PositionOccurrence(XML_Retorno,"<"+Xml_Atributo,firstRank,FromBeginning)
Final is int = PositionOccurrence(XML_Retorno,"</"+Xml_Atributo+">",lastRank,FromEnd) +Length("</"+Xml_Atributo+">")
XML_Retorno = Middle(XML_Retorno,Inicial,Final - Inicial)
XML_Retorno = Replace(XML_Retorno,Xml_Atributo,"NoXml")
XML_Retorno = "<Xml><Recorte>"+XML_Retorno+"</Recorte></Xml>"

nTotalxml is int = Length(XML_Retorno)

LOOP (nTotalxml)

X++
IFxposicaoinicial = 0 AND Xposicaofinal = 0 AND XML_Retorno[[X]] = "<" THEN
X++
IF XML_Retorno[[X]] = "/" THEN
xposicaoinicial = X + 1
END
END
IF xposicaoinicial > 0 AND XML_Retorno[[X]] = ">" THEN
Xposicaofinal = X
END
IF Xposicaofinal > 0 AND xposicaoinicial > 0 THEN
stag is string = Middle(XML_Retorno,xposicaoinicial,Xposicaofinal - xposicaoinicial)
IF stag="NoXml" THEN
BREAK
END
Add(arrXml_Tag, stag)
Xposicaofinal = 0
xposicaoinicial = 0
END

END

//iOS - Apple (iPhone / iPad / iPod)
IF IniOSMode() = True THEN

NoXml is string
i is int = 1
NoXml = XMLExtractString(XML_Retorno,"NoXml",i)

FOR EACH stag OF arrXml_Tag

temp is string = XMLExtractString(NoXml,stag)
Add(arrXml_TagResult, temp )

END

//Android
ELSE IF InAndroidMode() = True

XmlDoc is XMLDocument
XmlDoc = XMLOpen(XML_Retorno, fromString)
NoXml is xmlNode

FOR EACH NoXml OF XmlDoc.Xml.Recorte on NoXml

FOR EACH sTag OF arrXml_Tag

Add(arrXml_TagResult,NoXml..ChildNode[sTag])

END

END

END

RESULT arrXml_TagResult
Membre enregistré
2 962 messages
Popularité : +89 (91 votes)
Posté le 03 janvier 2015 - 17:49
:merci: