find_xpath | R Documentation |
This function finds matches for an XPath query in a corpus.
find_xpath(x, pattern, fun = NULL, final_fun = NULL, namespaces = NULL, ...)
x |
A corpus: an |
pattern |
An XPath query. |
fun |
Function to be applied to the individual nodes prior to returning the result. |
final_fun |
Function to be applied to the complete list of matches prior to returning the result. |
namespaces |
A namespace as generated by |
... |
Additional arguments. |
A nodeset or the output of applying fun
to a nodeset.
test_xml <- ' <p> <w pos="at">The</w> <w pos="nn">example</w> <punct>.</punct> </p>' find_xpath(test_xml, "//w") find_xpath(test_xml, "//@pos") find_xpath(test_xml, "//w[@pos='nn']") find_xpath(test_xml, "//w", fun = xml2::xml_text) find_xpath(test_xml, "//w", fun = xml2::xml_attr, attr = "pos")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.