How do I get back XML instead of JSON?


#1

Originally asked by Scot McSweeney-Roberts:

How do I get xml back instead of JSON? I tried adding &format=xml to the examples, but that didn’t help (and I don’t have any control over the Accept header, if that’s the way I’m supposed to specify it).


#2

The correct syntax is:

formatter=xml

For example:

https://api.tfl.gov.uk/Line/47/StopPoints?formatter=xml
https://api.tfl.gov.uk/StopPoint/Search?query=Elephant&maxResults=5&formatter=xml

As you mentioned, you can also do this with the HTTP Accept header e.g.:

$ curl -H "Accept: text/xml""https://api.tfl.gov.uk/Line/victoria/StopPoints"


How do I get back XML instead of JSON?