开发者

Extract data form linkedin connection object in ruby?

开发者 https://www.devze.com 2023-02-22 15:06 出处:网络
I am using linkedIn gem. https://github.com/pengwynn/linkedin Here is the code I am getting linkedin connections

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=[#,开发者_JS百科

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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消