问题描述
我正在尝试使用 xml2 库 (1.3.2) 从 html 文档中删除元素:
html <- "<html> <ul> <li>foo</li> </ul> </html>"
x <- read_html(html)
ul <- xml_find_first(x,".//ul")
xml_remove(x,ul)
结果:
Error in xml_remove.xml_node(x,ul) :
LOGICAL() can only be applied to a 'logical',not a 'list'
ul
似乎是正确的,属于具有正确内容的 xml_node 类。
是我搞砸了什么还是 xml2 库有问题?文档极其稀少。