Using rvest
, how to select nodes which have no attributes?
For example:
<nodes>
<node attribute1="aaaa"></node>
<node attribute1="bbbb"></node>
<node></node> <- FIND THIS
</nodes>
Here is a related thread using XPath, but when I try in rvest
with something similar to
wp %>% html_read(.) %>% html_nodes(xpath = "//node[not(@*)")
where wp
is the desired url, I error out with:
Warning message:
In xpath_search(x$node, x$doc, xpath = xpath, nsMap = ns, num_results = Inf) :
Invalid predicate [1206]
when I can see what I desire to scrape has no attributes in the page source.
To be frank, I just don't know enough about web development and HTML to understand how to generalize this example to rvest's doumentation. Any help or resources would be much appreciated!
EDIT:
The correct code to achieve this in rvest
is
wp %>% html_read(.) %>% html_nodes(xpath = "//node[not(@*)]")