Read data from xml feed?

Does anyone have advice on reading in XML data? An API I want to use for a project seems to only output XML data rather than JSON.


I haven’t seen good XML support (as in none) but one strategy I’ve used in the past is write a secondary light-weight webservice that can do translations. In your case, XML to JSON. I’ve had great luck with Heroku and Node JS. I know you can get XML parsers for Node, so it should be a simple matter. It is a little overkill, but may be your only option.

Pretty much the only other option is to use regular expressions…

I’ve seen implementations of basic XML parsing in pure Lua using regexp’s and used this strategy in the past. You have to handle fringe cases in a pretty manual way but with a well defined API it’s an approach to consider that removes all the complexity associated with hosting an intermediate web service.

Can you post the URL to your XML or display the XML results?
Also, what particular part (data) of the XML are you interested in getting?

We’ve done some work with XML before using regexs, it’s not pretty… but for simple applications it will get the job done.

We have a job in task tracker to look at XML parsing, but I believe it’s quite a ways down in priority.