0
我不知道为什么会出现这个错误?我试图使用XMLPARSE函数来解析像标题,链接,描述,日期&将它保存在数据帧格式的新闻内容,但它抛出错误,如...我不能分析此新闻内容
site = "http://www.federalreserve.gov/feeds/prates.xml"
doc <- tryCatch(xmlParse(site), error=function(e) e);
Unknown IO errorfailed to load external entity
"http://www.federalreserve.gov/feeds/prates.xml"
src <- xpathApply(xmlRoot(doc), "//item")
Error in UseMethod("xmlRoot") :no applicable method for 'xmlRoot'applied to an object of class "c('XMLParserErrorList', 'simpleError', 'error',
'condition')"
for (i in 1:length(src)) {
if (i==1) {
foo<-xmlSApply(src[[i]], xmlValue)
temp<-data.frame(t(foo), stringsAsFactors=FALSE)
DATA=data.frame(title=temp$title,link=temp$link,description=temp$description,pubDate=temp$pubDate)
}
else {
foo<-xmlSApply(src[[i]], xmlValue)
temp<-data.frame(t(foo), stringsAsFactors=FALSE)
temp1=data.frame(title=temp$title,link=temp$link,description=temp$description,pubDate=temp$pubDate)
DATA<-rbind(DATA, temp1)
}
}
Error: object 'src' not found
您应该将XML对象传递给'xmlParse',而不是URL。 –
该网站现在是https:// –
@chris这并不重要...我解析XML文件。 –