PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 25 → WX - Example Read Xml with Android and iOS - Lendo Xml com Android e iOS
WX - Example Read Xml with Android and iOS - Lendo Xml com Android e iOS
Débuté par BOLLER, 28 juil. 2017 15:25 - Aucune réponse
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 28 juillet 2017 - 15:25
Procedure Android_iOs_ReadXml(XML_Retorno is string, Xml_Atributo is string )

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

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

nTotalxml is int = Length(XML_Retorno)

LOOP (nTotalxml)

X++
IF xposicaoinicial = 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

IF ArrayCount(arrXml_Tag) > 0 THEN
NoXml is string
i is int = 0
LOOP
i++
NoXml = XMLExtractString(XML_Retorno,"NoXml",i)
IF NoXml = "" THEN

BREAK

END
FOR EACH stag OF arrXml_Tag

temp is string = XMLExtractString(NoXml,stag)

Add(arrXml_TagResult, temp )

END
END
END

RESULT arrXml_TagResult


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/