当我运行这段代码时,我得到了错误。不确定为什么会发生这种情况。我使用的是Rstudio 64位
library(XML)
fileURL <- "https://www.w3schools.com//xml//simple.xml"
docs <- xmlTreeParse(fileURL,useInternal=TRUE)
rootNode <- xmlRoot(docs)
xmlName(rootNode)
错误如下所示
xmlName(rootNode) in xmlName(rootNode)错误:找不到对象'rootNode‘
发布于 2019-04-23 03:10:31
只需调用readLines
来检索URL页面的内容。通常,您可以使用isURL=TRUE
参数加载URL,但xmlTreeParse
不支持https
,而是每个docs支持http
或ftp
isURL指示文件参数是否引用URL (可通过ftp或http访问)
content <- readLines(fileURL)
docs <- xmlTreeParse(content, useInternal=TRUE)
rootNode <- xmlRoot(docs)
xmlName(rootNode)
# [1] "breakfast_menu"
https://stackoverflow.com/questions/55798180
复制相似问题