I would do a loop, something like this. Presumably you want these in your database so I'd store them in the database via a match model.
doc.xpath('//events/event').each do |event|
eventdate = event.xpath('event_datetimeGMT').text
end
Pregunta
im new to web development, and im trying to learn how all of this works. Ive managed to learn alot in 1 day but im stuck now.
Im trying to create an odds site so im using this xml feed to get all the info. Im able to do a
http://xml.pinnaclesports.com/pinnacleFeed.aspx?sportType=Hockey&contest=no
eventdate = doc.css('event_datetimeGMT')[0].text
league = doc.css('league')[0].text
visitingteam = doc.css('participant_name')[0].text
hometeam = doc.css('participant_name')[1].text
However Im looking to be more efficient and wondering whats the best way to go to collect all the games, should i run a loop or something? Also Im thinking I should store these in an array instead? Maybe run a loop to store each event in a separate array.
So lost, thanks in advance!
Solución
I would do a loop, something like this. Presumably you want these in your database so I'd store them in the database via a match model.
doc.xpath('//events/event').each do |event|
eventdate = event.xpath('event_datetimeGMT').text
end