xml_find_text: Extract the text from the first node that matches an xpath...

Description Usage Arguments Value Examples

View source: R/xml.R

Description

This is a helper function that uses xml_find_first to retrieve a node and then extracts the text from that node.

Usage

1
xml_find_text(x, xpath, ns = xml_ns(x), trim = FALSE)

Arguments

x

A document, node or node set

xpath

A string containing a xpath (1.0) expression

ns

Optionally, a named vector giving prefix-url pairs, as produced by xml_ns(). If provided, all names will be explicitly qualified with the ns prefix, i.e. if the element bar is defined in namespace foo, it will be called foo:bar. (And similarly for attributes). Default namespaces must be given an explicit name. The ns is ignored when using xml_name<-() and xml_set_name().

trim

If TRUE will trim leading and trailiing spaces

Value

A character vector.

Examples

1
2
x <- xml2::read_xml("<a>foo</a>")
xml_find_text(x, "/a")

tobiasziegler/aecfeedr documentation built on April 9, 2021, 10:45 a.m.