Skip to content

Instantly share code, notes, and snippets.

@releu
Created November 24, 2011 15:59
Show Gist options
  • Save releu/1391678 to your computer and use it in GitHub Desktop.
Save releu/1391678 to your computer and use it in GitHub Desktop.
Sax
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