just a simple question here. How can I get the return value on this kind of 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
Please see that I am getting Facebook name and Facebook ID
Is there any way about that?
EDIT
I found out that it is not an xml but rather A JSON (sorry) now my question really is how can I incorporate that returned value?
EDIT SECOND
Sir this what I am doing
Parsing it through this
static final String URL_FBFRIEND ="Some URL"+ "getFBFriends.php";
Now using that I can now parse some data by using my input values. Here is the code
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();
}
See that I am logging the returned xml Log.i(“xml-return”,””+ xml_getMembermob); And thats the output
Sir Ive altered your code`
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;
}
I am getting an error here ** fbTagValue = userData.substring(startFbTag, endFbTag – startFbTag);**
what seems to be the problem
This is pretty horrible format. It’s not XML. It’s not JSON. Assuming you’ve already got some sort of
Userclass, and that all the data is in a singleString, you could write something like this (completely untested):