-3
  Getting the  linkedin user profile

     my $profile_xml = $li->request(
                       request_url         => 'http://api.linkedin.com/v1/people/~:(id,first-name,last-name,positions,industry,distance)',
                       access_token        => $access_token->{token},
                       access_token_secret => $access_token->{secret},

);

我得到了结果,但我想分别获取 id、名字、姓氏。如何使用 GetElementByTheTagName 来检索值。

4

2 回答 2

0

如果您能够像这样管理 xml 内容:

 $str = '<id>bYdSs9C</id><first-name>Jack</first-name> <last-name>Rudloph</last-name>';

我们可以使用它来获取字段

while ($str =~ /<.*?>(.*?)<\/.*?>/g) {
        print $1, "\n";
}
于 2013-09-10T07:48:02.993 回答
0

Here i am showing that how to parse the linked profile values from xml which is received in the response but not by the GetElementbyTheTagname.

  my $parser = XML::Parser->new( Style => 'Tree' );
  my $tree   = $parser->parse( $profile_xml );
  print Dumper( $tree );

  my $UID = $tree->[1]->[4]->[2],"\n";
  print "User ID:$UID";
  print"</br>";

This is the way we can parse the values from the received response.

于 2013-09-11T10:12:55.117 回答