diff --git a/lib/roo/utils.rb b/lib/roo/utils.rb index 484d9190..dcaedde5 100644 --- a/lib/roo/utils.rb +++ b/lib/roo/utils.rb @@ -81,8 +81,9 @@ def load_xml(path) # Yield each element of a given type ('row', 'c', etc.) to caller def each_element(path, elements) + elements = Array(elements) Nokogiri::XML::Reader(::File.open(path, 'rb'), nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS).each do |node| - next unless node.node_type == Nokogiri::XML::Reader::TYPE_ELEMENT && Array(elements).include?(node.name) + next unless node.node_type == Nokogiri::XML::Reader::TYPE_ELEMENT && elements.include?(node.name) yield Nokogiri::XML(node.outer_xml).root if block_given? end end