在R中下载/解析XML文件时出错

在R中下载/解析XML文件时出错,xml,r,Xml,R,我试过这个 xmlUrl <- "http://www.w3schools.com/xml/simple.xml" doc <- xmlTreeParse(xmlUrl, useInternalNodes = T) 我尝试了以下解决方法: xmlUrl <- "http://www.w3schools.com/xml/simple.xml" download.file(xmlUrl, "./data/w3schools.xml", method = "curl") doc &

我试过这个

xmlUrl <- "http://www.w3schools.com/xml/simple.xml"
doc <- xmlTreeParse(xmlUrl, useInternalNodes = T)
我尝试了以下解决方法:

xmlUrl <- "http://www.w3schools.com/xml/simple.xml"
download.file(xmlUrl, "./data/w3schools.xml", method = "curl")
doc <- htmlTreeParse("./data/w3schools.xml", useInternalNodes = T)

xmlUrl您应该尝试以下方法:

fileUrl = "http://www.w3schools.com/xml/simple.xml"

download.file(fileUrl, destfile = "G:/Cleaning Data/data2/food.xml")

doc = xmlTreeParse(file = "G:/Cleaning Data/data2/food.xml", useInternalNodes = TRUE)

您应该尝试以下方法:

fileUrl = "http://www.w3schools.com/xml/simple.xml"

download.file(fileUrl, destfile = "G:/Cleaning Data/data2/food.xml")

doc = xmlTreeParse(file = "G:/Cleaning Data/data2/food.xml", useInternalNodes = TRUE)

您应该尝试以下方法:

fileUrl = "http://www.w3schools.com/xml/simple.xml"

download.file(fileUrl, destfile = "G:/Cleaning Data/data2/food.xml")

doc = xmlTreeParse(file = "G:/Cleaning Data/data2/food.xml", useInternalNodes = TRUE)

您应该尝试以下方法:

fileUrl = "http://www.w3schools.com/xml/simple.xml"

download.file(fileUrl, destfile = "G:/Cleaning Data/data2/food.xml")

doc = xmlTreeParse(file = "G:/Cleaning Data/data2/food.xml", useInternalNodes = TRUE)

如果您使用的是XML包,则url参数存在一些问题。 下面的代码可以工作。请试一试

library(XML)

fileUrl <- "http://www.w3schools.com/xml/simple.xml"
download.file(fileUrl, destfile = "./data/simple.xml")

doc <- xmlTreeParse("./data/simple.xml", useInternalNodes = TRUE)

库(XML)

fileUrl如果您使用的是XML包,那么url参数存在一些问题。 下面的代码可以工作。请试一试

library(XML)

fileUrl <- "http://www.w3schools.com/xml/simple.xml"
download.file(fileUrl, destfile = "./data/simple.xml")

doc <- xmlTreeParse("./data/simple.xml", useInternalNodes = TRUE)

库(XML)

fileUrl如果您使用的是XML包,那么url参数存在一些问题。 下面的代码可以工作。请试一试

library(XML)

fileUrl <- "http://www.w3schools.com/xml/simple.xml"
download.file(fileUrl, destfile = "./data/simple.xml")

doc <- xmlTreeParse("./data/simple.xml", useInternalNodes = TRUE)

库(XML)

fileUrl如果您使用的是XML包,那么url参数存在一些问题。 下面的代码可以工作。请试一试

library(XML)

fileUrl <- "http://www.w3schools.com/xml/simple.xml"
download.file(fileUrl, destfile = "./data/simple.xml")

doc <- xmlTreeParse("./data/simple.xml", useInternalNodes = TRUE)

库(XML)


fileUrl第一个适合我。我正在使用最新版本的R和XML包。@user227710我已经更新了问题。你现在能检查一下你的系统吗?使用此解决方法时是否出现错误?对于第二种方法,您可以省略
method=curl
,它可以正常工作。虽然出于各种原因您可能需要使用
XML
包,但从长远来看,您可能会发现使用
xml2
rvest
更容易(同样,这取决于您需要做的工作).第一个对我有用。我正在使用最新版本的R和XML包。@user227710我已经更新了问题。你现在能检查一下你的系统吗?使用此解决方法时是否出现错误?对于第二种方法,您可以省略
method=curl
,它可以正常工作。虽然出于各种原因您可能需要使用
XML
包,但从长远来看,您可能会发现使用
xml2
rvest
更容易(同样,这取决于您需要做的工作).第一个对我有用。我正在使用最新版本的R和XML包。@user227710我已经更新了问题。你现在能检查一下你的系统吗?使用此解决方法时是否出现错误?对于第二种方法,您可以省略
method=curl
,它可以正常工作。虽然出于各种原因您可能需要使用
XML
包,但从长远来看,您可能会发现使用
xml2
rvest
更容易(同样,这取决于您需要做的工作).第一个对我有用。我正在使用最新版本的R和XML包。@user227710我已经更新了问题。你现在能检查一下你的系统吗?使用此解决方法时是否出现错误?对于第二种方法,您可以省略
method=curl
,它可以正常工作。虽然出于各种原因您可能需要使用
XML
包,但从长远来看,您可能会发现使用
xml2
rvest
更容易(同样,这取决于您需要做的工作)我不明白为什么这个答案对我有效。我不明白为什么这个答案对我有效。我不明白为什么这个答案对我有效。我不明白为什么这个答案对我有效。我不明白为什么这个答案对我有效