Created
November 24, 2011 15:59
-
-
Save releu/1391678 to your computer and use it in GitHub Desktop.
Sax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Epay::BankXMLCatcher | |
BANK = 'bank' | |
include XML::SaxParser::Callbacks | |
attr_reader :bank_xml | |
def initialize | |
@bank_xml = "" | |
@in_bank = false | |
end | |
def on_start_element_ns(name, attributes, prefix, uri, namespaces) | |
@in_bank = true if name == BANK | |
end | |
def on_characters(chars) | |
@bank_xml << chars if @in_bank | |
end | |
def on_end_element_ns(name, prefix, uri) | |
@in_bank = false if name == BANK | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment