Parsing small web page with xml2 throws XML_PARSE_HUGE error

走远了吗. 提交于 2019-12-08 04:35:58

问题


Recently a user of my rNOMADS package in R began getting unexpected errors:

Error: Excessive depth in document: 256 use XML_PARSE_HUGE option [1]

We tracked the issue down to this command:

html.tmp <- xml2::read_html("http://nomads.ncep.noaa.gov/cgi-bin/filter_rap.pl?dir=%2Frap.20151120")

Upon following the link, it appears that the web page to be parsed is no larger than other ones that work fine, and much less than the 1 megabyte limit that should require the XML_PARSE_HUGE option. Furthermore,

xml2::read_html

actually has no XML_PARSE_HUGE option anyway. The only other potential solution, described here, is not appropriate for an official R package.

What is the cause of this error, and is it possible to resolve it without resorting to solutions outside the official CRAN repository?


回答1:


The best I can do so far is to install shabbychef's forked version of xml2 that forces XML_PARSE_HUGE. You can install this version of xml2 via

library(drat)
drat:::add("shabbychef")
install.packages('xml2')

For the time being, please use this work around if you encounter XML_PARSE_HUGE errors in rNOMADS.



来源:https://stackoverflow.com/questions/33819103/parsing-small-web-page-with-xml2-throws-xml-parse-huge-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!