Forum Academy Marketplace Showcase Pricing Features

API to Convert XML to JSON

Hi everyone, I just wanted to share a tool that might be helpful for some of you that deal with integrating feeds in your Bubble apps.

The Problem: Can’t Read All XML Attributes

When I hook an XML to my Bubble app via the API Connector, I have data that are within the attributes for example:

<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>

The problem I ran into was trying to parse the attribute values (such as en-US from locale) through the API Connector - it wouldn’t read it when I initialize the call.

Solution: XML to JSON Converter API

While there are plenty of XML to JSON converters available, none of them would convert a feed with live data that’s constantly changing and updating.

That’s where I developed an API that converts dynamic XML feeds to JSON. As a result, I’m able to parse those attribute values in a JSON format:

"item": [
    {
        "@contentType": "tv_episode",
        "@contentId": "df9c946a-e891-11ea-adc1-0242ac120002",
        "pubDate": "2020-03-26T11:39:57-05:00",
        "title": {
            "@locale": "en-US",
            "#text": "Episode Title"
        },
        "description": {
            "@locale": "en-US",
            "#text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
        },
        "rating": {
            "@systemCode": "us-tv",
            "#text": "TV-14"
        },
        "artwork": {
            "@url": "https://example.com/image.jpg",
            "@type": "tile_artwork",
            "@locales": "en-US"
        }
    }
]

Now Bubble’s API Connector can properly parse my attribute values while also getting the most recent XML data. To use the API, simple use the following link below:

https://api.factmaven.com/xml-to-json?xml=http://example.com/feed.xml

Just add you XML feed URL in the parameter (xml=...).

5 Likes

Thanks.
2 years ago I gave up a project for a client because of this missing feature

1 Like

Sorry to hear. I developed this 3 years ago, just never got around to mentioning it to the community. Hopefully this will help you with any future projects.

1 Like

I found the solution on that link thanks guys for helping using api response in this way helps me alot How to convert SOAP response to PHP Array?

I came across the exact same issue and reported it as a bug on Saturday, they’ve pushed a fix for it now. Yet to test it properly but it seems it’s working as expected.

image