Web API Return XML - How to Convert to JSON

Alright you power Thunkers. I’m cashing in some makers, because I’m in the :poop:

I’m working with a WebAPI that is returning XML. Why, because it is a HARDWARE company, not a SOFTWARE company. :frowning:

Here are my constraints:

  • Lim f(solution) = Thunkable
  • prefer flexible solution
  • Unafraid of using firebase hosting
  • Any TPA (third party applications) must be 100% free

I’m not 100% against going full-bore Mighty-Morphing-Power-Rangers on combining, TPAs but the closer I can keep it to native Thunkable, the happier I will be.

Here is a sample of the response I am receiving. Of course, I would prefer a flexible solution, but if I am forced to hard-code the XML hierarchy, I guess I will

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<response>
<feedMessageResponse>
<count>2</count>
<feed>
<id>0IMiUuM0ZD3er3bv8zndqdxqnjHVhSA0a</id>
<name>DrTed</name>
<description>DrTed</description>
<status>ACTIVE</status>
<usage>0</usage>
<daysRange>7</daysRange>
<detailedMessageShown>true</detailedMessageShown>
<type>SHARED_PAGE</type>
</feed>
<totalCount>2</totalCount>
<activityCount>0</activityCount>
<messages>
<message clientUnixTime="0">
<id>1514978703</id>
<messengerId>0-3553617</messengerId>
<messengerName>TedSpot</messengerName>
<unixTime>1607550566</unixTime>
<messageType>UNLIMITED-TRACK</messageType>
<latitude>44.5346</latitude>
<longitude>-123.25397</longitude>
<modelId>SPOT3</modelId>
<showCustomMsg>Y</showCustomMsg>
<dateTime>2020-12-09T21:49:26+0000</dateTime>
<batteryState>GOOD</batteryState>
<hidden>0</hidden>
<altitude>89</altitude>
</message>
<message clientUnixTime="0">
<id>1514975409</id>
<messengerId>0-3553617</messengerId>
<messengerName>TedSpot</messengerName>
<unixTime>1607550110</unixTime>
<messageType>OK</messageType>
<latitude>44.53466</latitude>
<longitude>-123.25397</longitude>
<modelId>SPOT3</modelId>
<showCustomMsg>Y</showCustomMsg>
<dateTime>2020-12-09T21:41:50+0000</dateTime>
<batteryState>GOOD</batteryState>
<hidden>0</hidden>
<messageContent>Everything is good on my ride.</messageContent>
<altitude>0</altitude>
</message></messages>
</feedMessageResponse>
</response>
1 Like

Hi,use this api

https://api.factmaven.com/xml-to-json/?xml=YOUR_XML

GitHub - factmaven/xml-to-json: Simple API that converts dynamic XML feeds to JSON through a URL or pasting the raw XML data. Made 100% in PHP.

1 Like

Thanks for the reference. I tried both my XML and the example the github provided and I get the same error.

Option 2: Paste Raw XML Data

https://api.factmaven.com/xml-to-json?xml=<item contentType="tv_episode" contentId="df9c946a-e891-11ea-adc1-0242ac120002"><pubDate>2020-08-27T11:39:57-05:00</pubDate><title locale="en-US">Episode Title</title><description locale="en-US">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</description><rating systemCode="us-tv">TV-14</rating><artwork url="https://example.com/image.jpg" type="tile_artwork" locales="en-US" /></item>

Error:
The website or service provider you are trying to reach does not support HTTPS requests.

If you have an XML string/site that works, I’d love to see it.

Cheers,

drted

1 Like

On iphone it works, but I saw that in webview it doesn’t work.
I also searched for an api to upload your xml code and send back a URL to post it but I can’t find any sorry track.

Hello, last time I tried to put a web viewer and display the answer on it.
It works great.
Do you have a way in JS to extract the content of this page on the Web viewer?

Or else it sets up your own XML converter it seems to me that it provides the index.php and you add the message function of the Web viewer to get the answer?

@kushweez ,

I ended up making a thunkable parser specific to this feed.

2 Likes