Hello i’m trying to get a list of titles including the link to the
corresponding list out of a xml response from an API.
This is the code i wrote:
require ‘net/http’
require ‘rexml/document’
login = “***”
password = “***”
Net::HTTP.start(‘www.wrts.nl’) {|http|
req = Net::HTTP::Get.new(’/api/lists’)
req.basic_auth login, password
response = http.request(req)
xml_data = (response.body)
doc = REXML::Document.new(xml_data)
names = REXML::XPath.match( doc, “/list-index//list” )
puts names.inner_text()
}
The response.body looks like this:
Taal op Maat Groep 23975143 Taal op Maat Groep 3 Week 1 Nederlands Nederlands 2009-12-03T22:40:33+01:00 2009-12-03T22:40:33+01:00 10 true 0 0 23975144 Taal op Maat Groep 3 Week 2 Nederlands Nederlands 2009-12-03T22:40:42+01:00 2009-12-03T22:40:42+01:00 9 true 0 0 ... 24743885 Taal Actief Groep 8 woordpakket 1 Nederlands Nederlands 2010-01-02T13:28:19+01:00 2010-01-02T13:28:19+01:00 24 true 0 0 *****What am i doing wrong here?