xml2 库删除节点:LOGICAL() 只能应用于 'logical',不能应用于 'list'
xml2 library remove node: LOGICAL() can only be applied to a 'logical', not a 'list'
我正在尝试使用 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
似乎是正确的,class xml_node 的内容正确。
是我搞砸了什么还是 xml2 库有问题?文档非常稀疏。
xml_remove(ul)
这是根据 manual 并且似乎有效。
> print(x)
{html_document}
<html>
[1] <body></body>
ul 不见了。
我正在尝试使用 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
似乎是正确的,class xml_node 的内容正确。
是我搞砸了什么还是 xml2 库有问题?文档非常稀疏。
xml_remove(ul)
这是根据 manual 并且似乎有效。
> print(x)
{html_document}
<html>
[1] <body></body>
ul 不见了。