Skip to content

Instantly share code, notes, and snippets.

@mojodna

mojodna/error.xml

Created Dec 10, 2008
Embed
What would you like to do?
<?xml version="1.0" encoding="utf-8"?>
<rsp stat="fail">
<err code="11" msg="Something bad happened" />
</rsp>
require 'rubygems'
require 'happymapper'
require 'pp'
class Error
include HappyMapper
attribute :code, Integer
attribute :message, String
end
class Rsp
include HappyMapper
# NOTE: tag "/rsp" helps, but doesn't seem necessary
attribute :stat, String
element :err, Error
end
error = File.read("error.xml")
pp Rsp.parse(error) # => []
pp Rsp.parse(error, :single => true) # => nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.