Method: REXML::Element#comments
- Defined in:
- lib/rexml/element.rb
#comments ⇒ Object
:call-seq:
comments -> array_of_comment_children
Returns a frozen array of the REXML::Comment children of the element:
xml_string = " <root>\n <!--foo-->\n <!--bar-->\n </root>\n"
d = REXML::Document.new(xml_string)
cs = d.root.comments
cs.frozen? # => true
cs.map {|c| c.class } # => [REXML::Comment, REXML::Comment]
cs.map {|c| c.to_s } # => ["foo", "bar"]
1432 1433 1434 |
# File 'lib/rexml/element.rb', line 1432 def comments find_all { |child| child.kind_of? Comment }.freeze end |