Skip to content
Advertisement

JSON Feed to RSS (Problems)

I am having a problem with converting a JSON feed into a RSS feed. I am attempting to do this in a single function, seen below.

I found code on GitHub — but it doesn’t work properly — and I don’t know how to fix it.

In the bottom of the PHP code: echo convert_jsonfeed_to_rss($content)."n"; I am expecting this to print out the RSS XML feed — it doesn’t.

JavaScript

I tried to put the $content variable before the convert_jsonfeed_to_rss function — same problem.

JavaScript

Advertisement

Answer

The conversion to a DOMDocument at the end seems to be the issue, it objects to a few parts of the document.

A quicker way (and seems to be more reliable in this case) is to just use dom_import_simplexml()

JavaScript

(from https://stackoverflow.com/a/799792/1213708).

Edit

From your updated code, you aren’t using the hierarchy properly (and probably don’t have errors enabled to show what is not working).

You need something like…

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement