Skip to contents

Get text from xml node

Usage

mclm_xml_text(node, trim = FALSE)

Arguments

node

XML node as read with xml2::read_xml().

trim

If TRUE will trim leading and trailing spaces.

Value

Character vector: The text value of the (elements of the) node, concatenated with spaces in between.

Examples

test_xml <- '
<p>
  <w pos="at">The</w>
  <w pos="nn">example</w>
  <punct>.</punct>
</p>'

test_xml_parsed <- xml2::read_xml(test_xml)

# xml2 output
xml2::xml_text(test_xml_parsed)
#> [1] "Theexample."

# mclm version
mclm_xml_text(test_xml_parsed)
#> [1] "The example ."