Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# XML FacebookAPI
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 18:03pm
Edited 9-Feb-12 19:15pm
v3
Comments
Uma Shankar Patel at 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 at 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
0 DamithSL 340
1 Maciej Los 282
2 OriginalGriff 203
3 ridoy 160
4 George Jonsson 90
0 OriginalGriff 7,953
1 DamithSL 6,139
2 Sergey Alexandrovich Kryukov 5,454
3 Maciej Los 5,293
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 10 Feb 2012
Copyright © CodeProject, 1999-2014
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