4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/musicbrainz/bindings/relations.rb', line 4
def parse(xml)
hash = { urls: {} }
xml.xpath('./relation-list[@target-type="url"]/relation').map do |xml|
next unless type = xml.attribute('type')
type = type.value.downcase.split(" ").join("_").to_sym
target = xml.xpath('./target').text
if hash[:urls][type].nil? then hash[:urls][type] = target
elsif hash[:urls][type].is_a?(Array) then hash[:urls][type] << target
else hash[:urls][type] = [hash[:urls][type]]; hash[:urls][type] << target
end
end
hash
end
|