我正在获取xml格式的输出
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<person>
<first-name>xxxxxxxxx</first-name>
<last-name>xxxxxxxx</last-name>
<email-address>xxxxxxxxxxxxxxxx</email-address>
</person>我想读取字符串形式的值,以便进一步使用它。我的代码如下:
String accesstok=AccessToken.toString();
OAuthRequest request2 = new OAuthRequest(Verb.GET,"https://api.linkedin.com/v1/people/~:(first-name,last-name,email-address)?oauth2_access_token="+accesstok);
Response response2 = request2.send();发布于 2014-11-29 19:38:52
这似乎与how to manipulate HTTP json response data in Java非常相似,也许其中的一些答案可以帮助你?我建议,就像我在那里做的那样,查看扫描器分隔符、Scanner.findInLine或Scanner.findWithinHorizon。
例如:
s.findWithinHorizon("<first-name>(\\w+)</first-name>");
MatchResult firstNameResult = s.match();
s.findWithinHorizon("<last-name>(\\w+)</last-name>");
MatchResult lastNameResult = s.match();
s.findWithinHorizon("<email-address>(\\w+)</email-address>");
MatchResult emailResult = s.match();https://stackoverflow.com/questions/27201763
复制相似问题