xml2::find_all_lgl() would return a logical vector indicating which nodes an xpath match was found on. However I can't seem to get the function to return a result other than an error. Anyone have examples of correct usage?
# how I expect it to work and what it would return x %>% xml_node("body") %>% xml_find_lgl("//div/p") #  TRUE TRUE FALSE # however the following is returned: # Error: result of type: 'list', not logical # body has 3 parent div nodes -- 2 of which have p nodes x <- read_html( "<html> <body> <div> <div> <p>text</p> <p>more text</p> </div> <div class='here'> <p>second nested div</p> </div> </div> <div> <p>no nested divs here</p> </div> <div> </div> </body> </html>")
There are no example usages of this function in 1.3.2, and the
xml2:::xml_find_lgl.xml_node() method calls C code, which I feel is beyond my comprehension because it appears to be the same as
xml2:::xml_find_all.xml_node() except it checks that the result is logical -- I don't know of any xpath that would return a logical result since they mostly appear to return a part of the document (node, attribute, text, etc).