I am trying to retrieve data in R from an oData source. This script worked, but after i updated some packages, the script required the xml2 package, which caused an error.
library('httr') # for sending http requests
library("xml2") # for reading xml
# log start of request
log_message(paste("Requesting OData from:",url))
# get the OData resource
response <- GET(url,authenticate(usr,pwd))
# parse xml docucument
responseContent <- content(response,type="text/xml")
# determine the names of the attributes
xmlNames <- xpathApply(responseContent,
'//ns:entry[1]//m:properties[1]/d:*',xmlName,
namespaces = c(ns = "http://www.w3.org/2005/Atom",
m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata",
d="http://schemas.microsoft.com/ado/2007/08/dataservices"))
When determining the names of the attributes i get the following error. Does anyone know what this error message means and how I can solve it?
Error in UseMethod("xpathApply") : no applicable method for 'xpathApply' applied to an object of class "c('xml_document', 'xml_node')"