soulcutter / saxerator

A SAX-based XML parser for parsing large files into manageable chunks
MIT License
128 stars 19 forks source link

How can I get a count of ? #64

Closed Serhii-Danovsky closed 6 years ago

Serhii-Danovsky commented 6 years ago
parser = Saxerator.parser(File.new(file))
parser.for_tag('RECORD').each_with_index do |item, index|
end

How can I get a count of all parser.for_tag('RECORD') elements?

fanantoxa commented 6 years ago

@Serhii-Danovsky Hi, sorry for late response.

Saxerator.parser(file).for_tag(:artist).count

Works.

Actually this is gem for SAX parsing, so your xml became a Stream of parsed nodes. It was made to allow not to load all xml file at once in memory.