xml - 无法从 https ://site 读取 XML 文件

标签 xml r https

运行 R 3.2.0、R Studio 0.99.441、Windows 7 32 位、XML 包 3.98-1.2

我正在尝试使用 XML 包和 xmlTreeParse 从下面的站点读取 XML 文件,但一直出现错误。

https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2Frestaurants.xml

> fileURL <- "https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2Frestaurants.xml"
> doc <- xmlTreeParse(fileURL, useInternal = TRUE)
Error: XML content does not seem to be XML: 'https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2Frestaurants.xml' 

我也试过 download.file() 和 xmlTreeParse

download.file(fileURL, destfile = "data.xml")
doc <- xmlTreeParse("data.xml", useInternalNodes = TRUE)

当我执行此操作时,不会立即出现错误,但变量“doc”没有结构,我不确定如何从这一点开始阅读它。

最佳答案

https 中删除 s :

fileURL <- "http://d396qusza40orc.cloudfront.net/getdata%2Fdata%2Frestaurants.xml"
fileURL <- sub('https', 'http', fileURL)
doc <- htmlParse(fileURL)

关于xml - 无法从 https ://site 读取 XML 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30714184/

相关文章:

https - 使用 FiddlerCore 将 HTTPS 请求捕获到不存在的服务器

ios - 防止 ios5 中的自签名 ssl 证书

java - 为什么 "class"不能用作 JAXB 中的标记名称

android - CardView 中心的 Fab 按钮

java - 如何将 XML 内容作为字符串获取

r - 在 kable 中插入空行

java - 如何将Java对象转换为XML字符串,反过来将XML转换为Java对象?

R 在轴表达式中导出带有 unicode 的 ggplot 对象时崩溃

R Shiny 数据表 : Format numbers not by column but by row

http - 在 nginx 中将所有 http 重定向到 https,除了一个文件