Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

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("
  
   \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"]

  

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

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}