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 best solutions below

0
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");