Skip to content

How to suppress errors generated by readHTMLTable?

2 messages · Peng Yu, Duncan Temple Lang

#
library(XML)

download.file('http://polya.umdnj.edu/polya_db2/gene.php?llid=109079&unigene=&submit=Submit','index.html')
tables=readHTMLTable("index.html",error=function(...){})
tables


readHTMLTable gives me the following errors. Could somebody let me
know how to suppress them?


Opening and ending tag mismatch: center and table
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
Opening and ending tag mismatch: td and tr
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
htmlParseEntityRef: expecting ';'
Unexpected end tag : form
Opening and ending tag mismatch: body and center
Opening and ending tag mismatch: body and center
#
Just this morning, I made suppressing these parser messages
the default behavior for htmlParse() and that will apply
to readHTMLTable() also.

Until I release that (along with another potentially
non-backward compatible change regarding character encoding),
you can use

 readHTMLTable(htmlParse("index.html", error = function(...){}))

i.e. parse the document yourself and hand it to readHTMLTable().

 D.
Peng Yu wrote: