How does nokogiri get the text text of an html element itself but does not contain the text text of a driver element?

  question, ruby
 <div id='div1'>111</div>
 <div id='div2'>222
 <div id='div3'>333
 <div id='div4'>444</div>
 <div id='div33'>bbb</div>

For example:
The text of the div2 element itself is 222. however, when using nokogiri to obtain the text text of div2, the text of all levels of child elements of div2, such as div3 and div4 text, will also be included.
But I only want div2’s own text, that is, 222.

require 'nokogiri'
 html = Nokogiri::HTML(open 'test.html')
 div2_obj = html.xpath("//*[@id='div2']")
 Div2_text = div2_obj.to_s # this will get the text of all levels of child elements of div2

So how can we only get the text text of div2 itself (that is, only 222, not 333 444 bbb)?

Div2_obj.children[0].text is div_obj’s own text text, 222, excluding 333,444 BBB