Click here to Skip to main content
15,883,840 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

C#
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



HTML
- <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
Updated 9-Feb-12 18:15pm
v3
Comments
uspatel 10-Feb-12 0:15am    
EDIT: code tag added.

1 solution

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
C#
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);
        }
    }
}
 
Share this answer
 
Comments
[no name] 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900