0
votes

I am using linkedIn gem.

https://github.com/pengwynn/linkedin

Here is the code I am getting linkedin connections

  @linkedin.authorize_from_access(auth_provider.token, auth_provider.secret)
  @connections = @linkedin.connections

I am getting connection as xml format. Here is the connection obj data

<%= debug connection%>

name="document" children=[#,

children=[#]>,

, #

name="first-name" children=[#]>,

, #

name="last-name" children=[#]>,

, #

name="headline" children=[#]>,

, #

name="location" children=[#,

children=[#]>,

, #

name="country" children=[#,

children=[#]>,

]>, #

"\n ">]>,

, #

name="industry" children=[#]>,

, #

name="api-standard-profile-request" children=[#,

children=[#]>,

, #

name="headers" attributes=[#] children=[#,

children=[#,

children=[#]>,

, #

name="value" children=[#]>,

]>, #

"\n ">]>,

]>, #

"\n ">,

children=[#,

children=[#]>,

]>, #

"\n ">]>]>>

How can I extract the data from this object to get connection name and their details?

1

1 Answers

0
votes

Seems like a perfect fit for Nokogiri:

http://nokogiri.org/

connection.xpath("//document").each do |document|
  first_name = document.xpath("/first-name").content
  ...
end

Here's an explanation of XPath that should help.