Method: NdrImport::Helpers::File::XmlStreaming#each_node
- Defined in:
- lib/ndr_import/helpers/file/xml_streaming.rb
#each_node(safe_path, xpath, &block) ⇒ Object
Streams the contents of the given ‘safe_path`, and yields each element matching `xpath` as they’re found.
In the case of dodgy encoding, may fall back to slurping the file, but will still use stream parsing for XML.
119 120 121 122 123 124 125 126 127 |
# File 'lib/ndr_import/helpers/file/xml_streaming.rb', line 119 def each_node(safe_path, xpath, &block) return enum_for(:each_node, safe_path, xpath) unless block require 'nokogiri' with_encoding_check(safe_path) do |stream, encoding| stream_xml_nodes(stream, xpath, encoding, &block) end end |