0
Convert XML API call response into JSON object.
Hi, after a successful call to a public API, the response that I get is of the following form:
{"result":"<Page><timestamp>2023-12-11T01:37:06.405</timestamp><contents><item><id>10381</id><code>N18</code><title>Χρόνια νεφρική ανεπάρκεια</title><description>Χρόνια νεφρική ανεπάρκεια</description><notUpdPharCost>false</notUpdPharCost><onlyByProtocol>false</onlyByProtocol><updateDate>2023-09-25 15:14:32</updateDate><insertDate>2000-01-01 00:00:00</insertDate><startDate>2023-01-01 00:00:00</startDate><endDate>2023-09-25 23:59:59</endDate><onlyByProtocolAgeLimit/></item><item><id>4929</id><code>N18.8</code><title>Άλλη χρόνια νεφρική ανεπάρκεια</title><description>Ουραιμική:\n νεφροπάθεια+ (G63.8*)\nπερικαρδίτιδα+ (I32.8*)\n\n\n\n\n\n\n\n\n\n\n\n\n\n</description><notUpdPharCost>false</notUpdPharCost><onlyByProtocol>false</onlyByProtocol><updateDate>2023-09-25 15:14:32</updateDate><insertDate>2000-01-01 00:00:00</insertDate><startDate>2023-01-01 00:00:00</startDate><endDate>2023-09-25 23:59:59</endDate><onlyByProtocolAgeLimit/></item><item><id>4930</id><code>N18.9</code><title>Χρόνια νεφρική ανεπάρκεια, μη καθορισμένη</title><description>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n</description><notUpdPharCost>false</notUpdPharCost><onlyByProtocol>false</onlyByProtocol><updateDate>2023-09-25 15:14:32</updateDate><insertDate>2000-01-01 00:00:00</insertDate><startDate>2023-01-01 00:00:00</startDate><endDate>2023-09-25 23:59:59</endDate><onlyByProtocolAgeLimit/></item></contents><count>3</count><totalEntries>3</totalEntries><totalPages>1</totalPages><firstPage>true</firstPage><lastPage>true</lastPage></Page>"}
Please let me know if I'm wrong, but the response result is in XML format. How could I convert it to a JSON object to access the individual parameters of the response body?
I have already tried to use the parseXML() function without success .
2 replies
-
Hi
Yes, parseXML() formula is the one to use. Test without the "result" label:
let myXML := "<Page><timestamp>2023-12-11T01:37:06.405</timestamp><contents><item><id>10381</id><code>N18</code><title>Χρόνια νεφρική ανεπάρκεια</title><description>Χρόνια νεφρική ανεπάρκεια</description><notUpdPharCost>false</notUpdPharCost><onlyByProtocol>false</onlyByProtocol><updateDate>2023-09-25 15:14:32</updateDate><insertDate>2000-01-01 00:00:00</insertDate><startDate>2023-01-01 00:00:00</startDate><endDate>2023-09-25 23:59:59</endDate><onlyByProtocolAgeLimit/></item><item><id>4929</id><code>N18.8</code><title>Άλλη χρόνια νεφρική ανεπάρκεια</title><description>Ουραιμική:\n νεφροπάθεια+ (G63.8*)\nπερικαρδίτιδα+ (I32.8*)\n\n\n\n\n\n\n\n\n\n\n\n\n\n</description><notUpdPharCost>false</notUpdPharCost><onlyByProtocol>false</onlyByProtocol><updateDate>2023-09-25 15:14:32</updateDate><insertDate>2000-01-01 00:00:00</insertDate><startDate>2023-01-01 00:00:00</startDate><endDate>2023-09-25 23:59:59</endDate><onlyByProtocolAgeLimit/></item><item><id>4930</id><code>N18.9</code><title>Χρόνια νεφρική ανεπάρκεια, μη καθορισμένη</title><description>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n</description><notUpdPharCost>false</notUpdPharCost><onlyByProtocol>false</onlyByProtocol><updateDate>2023-09-25 15:14:32</updateDate><insertDate>2000-01-01 00:00:00</insertDate><startDate>2023-01-01 00:00:00</startDate><endDate>2023-09-25 23:59:59</endDate><onlyByProtocolAgeLimit/></item></contents><count>3</count><totalEntries>3</totalEntries><totalPages>1</totalPages><firstPage>true</firstPage><lastPage>true</lastPage></Page>"; parseXML(myXML)
Fabio
Content aside
- Status Answered
- 1 yr agoLast active
- 2Replies
- 113Views
-
2
Following