0

这是我得到的输出,如何将其转换为 xml 文件。我什至想知道结果是什么。请帮我解决这个问题,因为我是 Rails 的新手。

[#<LinkedIn::Position::Resource:0x4a63e80 @position=#<Nokogiri::XML::Element:0x2531fa0 name="position" children=[#<Nokogiri::XML::Text:0x2531c
34 "\n      ">, #<Nokogiri::XML::Element:0x2531bf8 name="id" children=[#<Nokogiri::XML::Text:0x2531850 "252416522">]>, #<Nokogiri::XML::Text:0
x253155c "\n      ">, #<Nokogiri::XML::Element:0x253152c name="title" children=[#<Nokogiri::XML::Text:0x253122c "Senior Software Engineer">]>,
 #<Nokogiri::XML::Text:0x2531094 "\n      ">, #<Nokogiri::XML::Element:0x2530f8c name="summary" children=[#<Nokogiri::XML::Text:0x253089c "Wor
king on Ruby on Rails">]>, #<Nokogiri::XML::Text:0x2530308 "\n      ">, #<Nokogiri::XML::Element:0x252ff6c name="start-date" children=[#<Nokog
iri::XML::Text:0x252fb58 "\n        ">, #<Nokogiri::XML::Element:0x252fb28 name="year" children=[#<Nokogiri::XML::Text:0x252f960 "2012">]>, #<
Nokogiri::XML::Text:0x252f888 "\n        ">, #<Nokogiri::XML::Element:0x252f84c name="month" children=[#<Nokogiri::XML::Text:0x252f684 "1">]>,
 #<Nokogiri::XML::Text:0x252f5ac "\n      ">]>, #<Nokogiri::XML::Text:0x252f4d4 "\n      ">, #<Nokogiri::XML::Element:0x252f4a4 name="is-curre
nt" children=[#<Nokogiri::XML::Text:0x252efb8 "true">]>, #<Nokogiri::XML::Text:0x252ed6c "\n      ">, #<Nokogiri::XML::Element:0x252ed3c name=
"company" children=[#<Nokogiri::XML::Text:0x252e694 "\n        ">, #<Nokogiri::XML::Element:0x252e5ec name="id" children=[#<Nokogiri::XML::Tex
t:0x252e364 "203940">]>, #<Nokogiri::XML::Text:0x252e28c "\n        ">, #<Nokogiri::XML::Element:0x252e25c name="name" children=[#<Nokogiri::X
ML::Text:0x252e094 "AB Innovative Software Pvt. Ltd">]>, #<Nokogiri::XML::Text:0x252dfa4 "\n        ">, #<Nokogiri::XML::Element:0x252df68 nam
e="size" children=[#<Nokogiri::XML::Text:0x252dd40 "51-200 employees">]>, #<Nokogiri::XML::Text:0x252dc50 "\n        ">, #<Nokogiri::XML::Elem
ent:0x252dc20 name="type" children=[#<Nokogiri::XML::Text:0x252d9f8 "Privately Held">]>, #<Nokogiri::XML::Text:0x252d908 "\n        ">, #<Noko
giri::XML::Element:0x252d8d8 name="industry" children=[#<Nokogiri::XML::Text:0x252d6e0 "Computer Software">]>, #<Nokogiri::XML::Text:0x252d4d0
 "\n      ">]>, #<Nokogiri::XML::Text:0x252d2f0 "\n    ">]>>, #<LinkedIn::Position::Resource:0x4a63b80 @position=#<Nokogiri::XML::Element:0x25
31f1c name="position" children=[#<Nokogiri::XML::Text:0x252c588 "\n      ">, #<Nokogiri::XML::Element:0x252c444 name="id" children=[#<Nokogiri
::XML::Text:0x252bce8 "127229045">]>, #<Nokogiri::XML::Text:0x252bb80 "\n      ">, #<Nokogiri::XML::Element:0x252bb50 name="title" children=[#
<Nokogiri::XML::Text:0x252b1d8 "Software Engineer">]>, #<Nokogiri::XML::Text:0x252ac08 "\n      ">, #<Nokogiri::XML::Element:0x252ab48 name="s
ummary" children=[#<Nokogiri::XML::Text:0x2529c9c "Software Engineer">]>, #<Nokogiri::XML::Text:0x2529900 "\n      ">, #<Nokogiri::XML::Elemen
t:0x2529858 name="start-date" children=[#<Nokogiri::XML::Text:0x252930c "\n        ">, #<Nokogiri::XML::Element:0x25292dc name="year" children
=[#<Nokogiri::XML::Text:0x25287f0 "2011">]>, #<Nokogiri::XML::Text:0x2528664 "\n        ">, #<Nokogiri::XML::Element:0x25285e0 name="month" ch
ildren=[#<Nokogiri::XML::Text:0x2527cc8 "4">]>, #<Nokogiri::XML::Text:0x2527530 "\n      ">]>, #<Nokogiri::XML::Text:0x2527440 "\n      ">, #<
Nokogiri::XML::Element:0x2527410 name="end-date" children=[#<Nokogiri::XML::Text:0x2527248 "\n        ">, #<Nokogiri::XML::Element:0x2527218 n
ame="year" children=[#<Nokogiri::XML::Text:0x2527050 "2012">]>, #<Nokogiri::XML::Text:0x2526f78 "\n        ">, #<Nokogiri::XML::Element:0x2526
f3c name="month" children=[#<Nokogiri::XML::Text:0x2526d74 "1">]>, #<Nokogiri::XML::Text:0x2526a20 "\n      ">]>, #<Nokogiri::XML::Text:0x2526
948 "\n      ">, #<Nokogiri::XML::Element:0x2526918 name="is-current" children=[#<Nokogiri::XML::Text:0x2526738 "false">]>, #<Nokogiri::XML::T
ext:0x2526654 "\n      ">, #<Nokogiri::XML::Element:0x2526624 name="company" children=[#<Nokogiri::XML::Text:0x2526138 "\n        ">, #<Nokogi
ri::XML::Element:0x252609c name="id" children=[#<Nokogiri::XML::Text:0x2525a60 "11498">]>, #<Nokogiri::XML::Text:0x2525898 "\n        ">, #<No
kogiri::XML::Element:0x2525868 name="name" children=[#<Nokogiri::XML::Text:0x25256a0 "Onward Technologies">]>, #<Nokogiri::XML::Text:0x25255c8
 "\n        ">, #<Nokogiri::XML::Element:0x2525598 name="type" children=[#<Nokogiri::XML::Text:0x25253ac "Public Company">]>, #<Nokogiri::XML:
:Text:0x2525184 "\n        ">, #<Nokogiri::XML::Element:0x2525118 name="industry" children=[#<Nokogiri::XML::Text:0x2524f2c "Information Techn
ology and Services">]>, #<Nokogiri::XML::Text:0x2524e54 "\n        ">, #<Nokogiri::XML::Element:0x2524e24 name="ticker" children=[#<Nokogiri::
XML::Text:0x2524b48 "ONWARD">]>, #<Nokogiri::XML::Text:0x25247f4 "\n      ">]>, #<Nokogiri::XML::Text:0x2524110 "\n    ">]>>]

client.inspect 输出是

#<LinkedIn::Client:0x4a1a908 @csecret=\"jKf6ZYgf8JhMoIJ4\", @access_token=#<OAuth::AccessToken:0x4a1a2c0 @token=\"177ba9cd-3b8e-4776-a7f7-db3f60d6df68\", @response=#<Net::HTTPOK 200 OK readbody=true>, @secret=\"d4641509-703a-42ad-a42a-2bf9ac2a8d48\", @consumer=#<OAuth::Consumer:0x4a1a1d0 @secret=\"jKf6ZYgf8JhMoIJ4\", @key=\"cus7tde3g4pe\", @uri=#<URI::HTTPS:0x4a19450 URL:https://api.linkedin.com>, @options={:authorize_path=>\"/uas/oauth/authorize\", :scheme=>:header, :http_method=>:post, :proxy=>nil, :site=>\"https://api.linkedin.com\", :request_token_path=>\"/uas/oauth/requestToken\", :oauth_version=>\"1.0\", :signature_method=>\"HMAC-SHA1\", :access_token_path=>\"/uas/oauth/accessToken\"}, @http=#<Net::HTTP api.linkedin.com:443 open=false>>, @params={}>, @ctoken=\"cus7tde3g4pe\", @consumer=#<OAuth::Consumer:0x4a1a1d0 @secret=\"jKf6ZYgf8JhMoIJ4\", @key=\"cus7tde3g4pe\", @uri=#<URI::HTTPS:0x4a19450 URL:https://api.linkedin.com>, @options={:authorize_path=>\"/uas/oauth/authorize\", :scheme=>:header, :http_method=>:post, :proxy=>nil, :site=>\"https://api.linkedin.com\", :request_token_path=>\"/uas/oauth/requestToken\", :oauth_version=>\"1.0\", :signature_method=>\"HMAC-SHA1\", :access_token_path=>\"/uas/oauth/accessToken\"}, @http=#<Net::HTTP api.linkedin.com:443 open=false>>, @asecret=\"d4641509-703a-42ad-a42a-2bf9ac2a8d48\", @consumer_options={:authorize_path=>\"/uas/oauth/authorize\", :request_token_path=>\"/uas/oauth/requestToken\", :access_token_path=>\"/uas/oauth/accessToken\"}, @atoken=\"177ba9cd-3b8e-4776-a7f7-db3f60d6df68\">"
4

1 回答 1

3

啊,好吧,现在我明白了……试试这个:

data = Hash.from_xml(client.profile.to_s)

高频...

于 2012-04-12T11:30:45.277 回答