Use Texts To Find All Text Elements
Join the DZone community and get the full member experience.Join For Free
REXML::Element::texts returns all text elements within a leaf node.
doc_b = Document.new("I discovered this while browsing Use has_elements to find children in REXML [dzone.com]
\n333") #=> 456 ... > irb(main):434:0> doc_b.root.elements['a'].text #=> "\n" irb(main):433:0> doc_b.root.elements['a'].texts #=> ["\n", " ", " 456"]
Opinions expressed by DZone contributors are their own.