> Has anybody used sax parsing in ruby
Yes.
--
use.inject do |as, often| as.you_can - without end
parser = REXML::Parsers::SAX2Parser.new( DATA.read )
parser.listen :start_element do
|uri, locname, qname, atts|
puts "I am in start_element and was called with " <<
[uri, locname, qname, atts].inspect
end
parser.listen :characters do
| text |
puts %<I am in characters and was called with "#{text}">
end
#
# For all type of listeners see here:
# http://www.ruby-doc.org/core/classes/REXML/Parsers/SAX2Parser.html#M005185
# and for the paramters they take have a look at the corresponding method here:
# http://www.ruby-doc.org/core/classes/REXML/SAX2Listener.html
parser.parse
__END__
<root>
<node1>
<node2 att1="www">
content
</node2>
</node1>
</root>
HTH
Robert
--
http://ruby-smalltalk.blogspot.com/
---
Whereof one cannot speak, thereof one must be silent.
Ludwig Wittgenstein