can anyone help me to know how to add ags xmpp contact list to XML file and show from it into list view

125 views Asked by At

Can anyone help me to know how to add agsxmpp contact list to XML file.Then to show from XML into list view?

1

There are 1 answers

0
uksp On BEST ANSWER

create a class listcontact as below

namespace TingTong

{ 
    public class contacts
    {
        public string name { get; set; }
        public string image { get; set; }
        public string lastmessage { get;set; }
        public string unreaded { get; set; }
    }
}

Then in your page write the following

    List<contacts> listcontact = new List<contacts>();
    Xdoc = new XDocument(new XElement("Contacts"));
    MessageBox.Show(listcontact.Count.ToString());

    for (int i = 0; i < listcontact.Count; i++)
    {
        XElement xml = new XElement("Contact", new XElement("name", listcontact[i].name), new XElement("image", listcontact[i].image), new XElement("lastmessage", listcontact[i].lastmessage), new XElement("unreaded", listcontact[i].unreaded));

        if (Xdoc.Descendants().Count() > 0)
            Xdoc.Descendants().First().Add(xml);
        else
            Xdoc.Add(xml);
    }
    Xdoc.Save(sub + "\\Contacts\\ContactList.xml");