2011-10-06 16:30:46 +04:00

13 lines
347 B
Ruby

module MusicBrainz
class Base
def self.safe_get_attr xml, path, name
node = path.nil? ? xml : (xml.css(path).first unless xml.css(path).empty?)
node.attr(name) unless node.nil? or node.attr(name).nil?
end
def self.safe_get_value xml, path
xml.css(path).first.text unless xml.css(path).empty?
end
end
end