【问题标题】:Unknown IO errorfailed to load external entity未知 IO 错误无法加载外部实体
【发布时间】:2018-01-28 10:14:50
【问题描述】:

我正在尝试学习 R 中的文本挖掘。

不知道为什么会出现这个错误?

library(XML)
xml.url <- "http://www.w3schools.com/xml/plant_catalog.xml"
plants <- xmlParse(xml.url)
plants.l <- xmlToList(plants)
length(plants.l)

如果能得到任何帮助,我将不胜感激。

【问题讨论】:

标签: r xml


【解决方案1】:

您收到了XML 软件包的问题。它不适用于重定向(http -&gt; https,您的网址以http 开头)和https

您可以使用其他软件包来下载该文件。这是httr 的示例。

library(XML)
library(httr)
xml.url <- "http://www.w3schools.com/xml/plant_catalog.xml"
plants <- xmlParse(rawToChar(GET(xml.url)$content))
plants.l <- t(xmlToList(plants, simplify = TRUE))
length(plants.l)

我还添加了 t()simplify = TRUE,以便在 R 中创建一个漂亮而简单的列表。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-01-04
    • 1970-01-01
    • 2014-06-19
    • 2013-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多