When trying to parse a xml file I get always this error.
A simple script to reproduce it:
doc <- xmlRoot(xmlTreeParse("http://www.stat.purdue.edu/~mdw/490M/cdcatalog.xml"))
xpathSApply(doc, "//CATALOG/CD/PRICE", xmlValue)
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘saveXML’ for signature ‘"character"’
The following packages are loaded:
sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-apple-darwin13.1.0 (64-bit)
locale:
[1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] XML_3.98-1.1
loaded via a namespace (and not attached):
[1] tools_3.1.0
url <- "http://www.stat.purdue.edu/~mdw/490M/cdcatalog.xml"
doc <- xmlRoot(xmlTreeParse(url, useInternalNodes = TRUE))
xpathSApply(doc, "//CATALOG/CD/PRICE", xmlValue)
I think this has got to do with resolution of namespaces. useInternalNodes = TRUE is required for xpath to use getNodeSet()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With