Download API data that returns JSON format within XML

Asked

Viewed 187 times

-2

I am accessing a website that provides an API that returns the data in JSON format, but the data is returned inside an XML code in the format below:

<string xmlns="http://tempuri.org/">[arquivo JSON]</string>

How to extract this JSON file from within XML code?

1 answer

0


Try something like that:

    library(xml2)
library(magrittr)
library(jsonlite)

url <- "http://site/api/transparencia.asmx/json_frota_veiculos?fbclid=IwAR3YRmwhEGVcePgavCUDwsCmeb_Z4ddgIwTH8Lp5Gv5elTy6fXRixkHFHeE"

page <- read_xml(url) %>% 
xml_text() %>% 
fromJSON()

Browser other questions tagged

You are not signed in. Login or sign up in order to post.