Hi guys.
I’m trying to mine some info from wikipedia’s xml dump. The code im
using is as follows:
require ‘rexml/parsers/sax2parser’
xml =
REXML::Parsers:SAX2Parser.new(File.new(‘enwiki-20070402-pages-articles-1.xml’)
)
i = 0
parser.listen(:characters, %w{title text}){|text| puts text}
parser.parse
Which is generating the error:
xmlreap.rb:2: undefined method `new’ for :SAX2Parser:Symbol
(NoMethodError)
Anyone have any experience with SAX2? Or ruby stream parsing in
general? What I’m trying to do is pretty simple: grab the title and
text tag element contents and do something with them.
Thanks,
Krister Johnson
On Sunday 06 May 2007, Krister Johnson wrote:
i = 0
parser.listen(:characters, %w{title text}){|text| puts text}
parser.parse
Which is generating the error:
xmlreap.rb:2: undefined method `new’ for :SAX2Parser:Symbol
(NoMethodError)
This is a syntax error. You have written
REXML::Parsers:SAX2Parser.new()
which, I guess, is interpreted as
REXML::Parsers(:SAX2Parser.new())
but :SAX2Parser is a symbol, and there is no new method on it …
You wanted (two ‘:’)
REXML::Parsers::SAX2Parser.new()
Krister Johnson wrote:
i = 0
parser.listen(:characters, %w{title text}){|text| puts text}
parser.parse
Which is generating the error:
xmlreap.rb:2: undefined method `new’ for :SAX2Parser:Symbol (NoMethodError)
Anyone have any experience with SAX2? Or ruby stream parsing in
general? What I’m trying to do is pretty simple: grab the title and
text tag element contents and do something with them.
I may have something useful here:
http://www.jamesbritt.com/content
oh no. that really was it. (slaps forehead)
thanks.
krister