Skip to content

Instantly share code, notes, and snippets.

@czottmann
Created January 2, 2009 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save czottmann/42597 to your computer and use it in GitHub Desktop.
Save czottmann/42597 to your computer and use it in GitHub Desktop.
module HappyMapper
class Item
private
def value_from_xml_node(node, namespace=nil)
node.register_default_namespace(namespace.chop) if namespace
if element?
depth = options[:deep] ? './/' : ''
result = node.find_first("#{depth}#{namespace}#{tag}")
if tag.match(/\/@[a-z\d]+$/i)
result ? result.value : nil
else
result ? result.content : nil
end
else
node[tag]
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment