Click here to Skip to main content
12,403,948 members (70,472 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# XML Facebook-API
I have a problem to display my name and my friends' names as individual Nodes, as I only get my friends' names without showing mine

public JsonObject GetMyProfile(string accessToken)
            {           
                FacebookClient client = new FacebookClient(accessToken);
                JsonObject me = client.Get("me/friends") as JsonObject;            
                return me;
            }

Right now this is the XML result I got
What I want is to display myself and my friends individually as a node



- <icedata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="InformationConnectionsEngine.data">
      - <currentnode>
      + <node id="[{" name=":" gerald="" brisco="," 508219894="},{" helena="" tanvis="" loi="," 508637920="},{" maryam="" nasihah="," 514469729="},{" enguo="" teo="," 520924077="},{" kimberley="" xd="," 521541857="},{" noor="" haikal="," 522010705="},{" simin="" lim="," 524160253="},{" pam="" wong="," 524430008="},{" jiuying="" chen="," 531272219="},{" jeremy="" heng="" witha="" angmohname="," 531785558="},{" shanel="" see="," 533346883="},{" aaron="" 533822559="},{" soonboon="" kaichito="" mogu="," 534857954="},{" kai="" cannottank="," 537247625="},{" stacey="" goh="," 541347137="}</xml>"></node></currentnode></icedata>
Posted 9-Feb-12 17:03pm
Updated 9-Feb-12 18:15pm
uspatel30.3K
v3
Comments
Uma Shankar Patel 10-Feb-12 0:15am
   
EDIT: code tag added.

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

I did something like that a while back never kept up with it. FB sends back JSON as you know. Basically what I ended up doing was create classes with public properties and used reflection to assign to the properties based on the json responses.

code looked like this
public static void jsonAssign(Type t, object otarg, JObject jo)
{
    PropertyInfo[] pis = t.GetProperties();
    object o;
    foreach (PropertyInfo pi in pis)
    {
        o = jo[pi.Name];
        if (o != null)
        {
 
            string val = o.ToString();
            int len = val.Length;
            if (val.StartsWith("\""))
                val = val.Substring(1, len - 1);
            len = val.Length;
            if (val.EndsWith("\""))
                val = val.Substring(0, len - 1);
 
            pi.SetValue(otarg, val, null);
        }
    }
}
  Permalink  
Comments
hoyeehong 10-Feb-12 1:21am
   
So basically I can't use both C# and XML together to generate my Nodes?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 10 Feb 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100