class Nokogiri::XML::DocumentFragment
def deconstruct
# #(Element:0x398 { name = "div", children = [ #(Text "End")] })]
# }),
# children = [ #(Text "shortcut")]
# attributes = [ #(Attr:0x384 { name = "href", value = "#jump" })],
# name = "a",
# #(Element:0x370 {
# => [#(Element:0x35c { name = "div", children = [ #(Text "Start")] }),
frag.elements.deconstruct
*Example* only the elements, not the text nodes.
# #(Text "\n")]
# #(Element:0x398 { name = "div", children = [ #(Text "End")] }),
# #(Text " for you.\n"),
# }),
# children = [ #(Text "shortcut")]
# attributes = [ #(Attr:0x384 { name = "href", value = "#jump" })],
# name = "a",
# #(Element:0x370 {
# #(Text "\n" + "This is a "),
# => [#(Element:0x35c { name = "div", children = [ #(Text "Start")] }),
frag.deconstruct
HTML
End
This is a shortcut for you.
Start
frag = Nokogiri::HTML5.fragment(<<~HTML)
*Example*
⚡ This is an experimental feature, available since v1.14.0
DocumentFragment#elements.
root elements, you should deconstruct the array returned by
💡 Note that text nodes are returned as well as elements. If you wish to operate only on
Returns the root nodes of this document fragment as an array, to use in pattern matching.
:call-seq: deconstruct() → Array
def deconstruct children.to_a end