iOS Question How to write XML file from HTTP Response

Falcon

Member
Licensed User
Hi Experts,

Please could someone give me the equivalent B4i code for the following B4a code:

B4X:
Response.GetAsynchronously("Response",File.OpenOutput(File.DirInternalCache,"Response.xml",False),True,TaskId)

What this did was write an XML file called 'Response.xml' from an HTTP Response.

Also what is the equivalent in B4i for:

B4X:
Response.Release

Thank you very much for your time,

Regards,
Jacques.
 

Falcon

Member
Licensed User
Hi Erel,

I am already using iHttpUtils2, but I do not how to write the incoming JSON server response to XML.
I can get the server response as a JSON string, I just need the code to convert the JSON to XML?

I found this link:

But it requires a reference to the JavaObject library which B4i does not have, please help.

Regards,
Jacques,
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
Include iJSON and Xml2Map libraries.

Convert JSON string (received from webserver) to Map
B4X:
    Dim JSONParser1 As JSONParser
    JSONParser1.Initialize (stringJSON)
    Dim Map1 As Map = JSONParser1.NextObject

Convert Map to XML
B4X:
    Dim Map2Xml1 As Map2Xml
    Map2Xml1.Initialize ()
    Dim stringXML = Map2Xml1.MapToXml (Map1)

Write string to a file (File.WriteString).
 
Upvote 0
Top