更新时间:2022-11-11 11:56:35
NodeSet#text
总是返回一个字符串(否则它可能被称为 NodeSet#texts
).Nokogiri 文档不是很好,如有疑问,请查看源代码:
NodeSet#text
always returns a string (otherwise it would probably be called NodeSet#texts
). Nokogiri docs are not so great, when in doubt check the source code:
# lib/nokogiri/xml/node_set.rb
def inner_text
collect{|j| j.inner_text}.join('')
end
alias :text :inner_text
获取文本数组:nodes.map(&:text)