sorting FQL data

Jan 16, 2010 at 9:48 PM

I've got an xml output of an FQL query looking like this:

 

<?xml version="1.0" encoding="UTF-8"?>
<fql_query_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" list="true">
  <user>
    <name>name1</name>
    <sex>male</sex>
    <pic_square>pic1.jpg</pic_square>
  </user>
  <user>
    <name>name2</name>
    <sex>female</sex>
    <pic_square>pic2.jpg</pic_square>
  </user>
  <user>
    <name>namex</name>
    <sex>female</sex>
    <pic_square>picx.jpg</pic_square>
  </user>
</fql_query_response>

 

 

Now I want to get an output out of this looking like this:

 

name1, male, pic1
name2, female, pic2 namex, female, picx

 

what is the best way to do this?

The closest till now I'v got is somthing like this

name1, name2, name3
male, female, female
pic1, pic2, pic3

with following code:

 

        private void btn_Getlist_Click(object sender, EventArgs e)
        {
            tbx_QueryOutput2.Clear();

            string queryoutput = facebookService1.Fql.Query("SELECT name, sex, pic_square FROM user WHERE uid IN ( SELECT uid2 FROM friend WHERE uid1= 1642996132)");

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(queryoutput);

            XmlNodeList nameList = xmlDoc.GetElementsByTagName("name");
            XmlNodeList sexList = xmlDoc.GetElementsByTagName("sex");
            XmlNodeList picList = xmlDoc.GetElementsByTagName("pic_square");

            foreach (XmlNode node in nameList)
            {
                if (!String.IsNullOrEmpty(node.InnerText))
                {
                    tbx_QueryOutput2.AppendText(node.InnerText + ",");
                }
            }
            tbx_QueryOutput2.AppendText(Environment.NewLine);
            foreach (XmlNode node in sexList)
            {
                if (!String.IsNullOrEmpty(node.InnerText))
                {
                    tbx_QueryOutput2.AppendText(node.InnerText + ",");
                }
            }
            tbx_QueryOutput2.AppendText(Environment.NewLine);
            foreach (XmlNode node in picList)
            {
                if (!String.IsNullOrEmpty(node.InnerText))
                {
                    tbx_QueryOutput2.AppendText(node.InnerText + ",");
                }
            }
            tbx_QueryOutput2.AppendText(Environment.NewLine);
        }

 

how can I best read out the xml to get a result that I want?

thx in advance