Description Usage Arguments Details Value Examples
Return an XML text value if provided the document and Xpath.
1 | xml_get_text(x, xpath)
|
x |
XML document: a literal XML document, a URL, or a string. |
xpath |
A string containing a xpath (1.0) expression. |
Serves as a convenience function. Utilizes xml_find_first
and xml_text and will return NA_character_
if the XML
text cannot be located or an error occurs.
Because the function uses xml_find_first, only the first match is returned.
XML text as a string or NA_character_
if an error occurs.
1 2 3 4 5 6 7 8 9 10 11 12 | xml_doc <- "
<root_tag>
<another_tag>
<var_text>10</var_text>
<var_attr value=\"10\"></var_attr>
</another_tag>
</root_tag>
"
ten <- xml_get_text(xml_doc,
"//root_tag/another_tag/var_text")
identical(ten, "10")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.