parse xml data from xml response.body

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('') {|http|    req ='/api/lists')    req.basic_auth login, password    response = http.request(req)    xml_data = (response.body)

doc = names = REXML::XPath.match( doc, "/list-index//list" ) puts names.inner_text() }

Well REXML::XPath.match( doc, “/list-index//list” ) will return a list of list elements so I wouldn’t expect inner_text() to make a lot of sense. Perhaps something like this

titles = REXML::XPath.match( doc, “/list-index/group/list/title/text()” )

titles.each{|title| puts title}

would work?

Yes it worked for me. It returns data in an array. But i'm not able to print some html with the variable in it.

titles.each{|title| puts "<a href=\"#\">#{title}</a> /n"}

It just prints the whole array.

How can i fix this?