这里只是一个简单的问题。如何获得这种 xml 的返回值
Art C. Cauyao<$@FBID@$>501912568<$@ENDFBID@$>Tessa Rose
Brainard<$@FBID@$>510831686<$@ENDFBID@$>
Dan Gangan<$@FBID@$>513545777<$@ENDFBID@$>
C Jhec DawAko<$@FBID@$>523059320<$@ENDFBID@$>Jeremy
请查看我正在获取 Facebook 名称和 Facebook ID 有什么办法吗?
编辑
我发现它不是一个 xml 而是一个 JSON(对不起)现在我的问题真的是如何合并该返回值?
编辑第二 先生这是我在做什么通过这个解析它
static final String URL_FBFRIEND ="Some URL"+ "getFBFriends.php";
现在使用它,我现在可以使用我的输入值解析一些数据。这是代码
XMLparser parser2 = new XMLparser();
parser2.getXmlFromUrl(URL_FBFRIEND);
//HTTP POST
String url_Getmembermob= URL_FBFRIEND ;
String xml_getMembermob=null;
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url_Getmembermob);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(4);
nameValuePairs.add(new BasicNameValuePair("...", "...."));
nameValuePairs.add(new BasicNameValuePair("fbID", modGen.facebookID ));
nameValuePairs.add(new BasicNameValuePair("accToken", modGen.tokenID));
nameValuePairs.add(new BasicNameValuePair("reqType", "0"));
Log.i("nameValuePairs", "nameValuePairs=" + nameValuePairs);
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse httpResponse = httpclient.execute(httppost);
HttpEntity httpEntity = httpResponse.getEntity();
xml_getMembermob = EntityUtils.toString(httpEntity);
Log.i("xml-return",""+ xml_getMembermob);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
看到我正在记录返回的 xml Log.i("xml-return",""+ xml_getMembermob); 这就是输出
先生,我改变了你的代码` public static List parseUserList(String userData) { List ret = new ArrayList();
int index = 0;
while (index < userData.length())
{
int startFbTag = userData.indexOf(FB_NAME, index);
if (index == -1)
{
return ret;
}
String name = userData.substring(index, startFbTag - index);
startFbTag += FB_NAME.length(); // Start of the actual data
int endFbTag = userData.indexOf(FB_ID, startFbTag);
if (endFbTag == -1)
{
throw new IllegalArgumentException("Unterminated start tag");
}
fbTagValue = userData.substring(startFbTag, endFbTag - startFbTag);
Log.i("UserName",fbTagValue);
//fbId = Long.parseLong(fbTagValue);
//ret.add(new User(name, fbId));
index = endFbTag + FB_ID.length();
}
return ret;
}
我在这里遇到错误 ** fbTagValue = userData.substring(startFbTag, endFbTag - startFbTag);** 似乎是什么问题