Over a million developers have joined DZone.

Use Texts To Find All Text Elements

DZone's Guide to

Use Texts To Find All Text Elements

Free Resource
REXML::Element::texts returns all text elements within a leaf node.

doc_b = Document.new("
irb(main):434:0> doc_b.root.elements['a'].text
#=> "\n"
irb(main):433:0> doc_b.root.elements['a'].texts
#=> ["\n", "  ", "  456"]


I discovered this while browsing Use has_elements to find children in REXML [dzone.com]

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}