locked
Windows Store App /Phone App XML as Database RRS feed

  • Question

  • Hi All,

    I was trying use XML as Database for my Store and Phone App,  I read the below blog it works perfect lyfor web, but doesnt create XML elements , I though modified the code as I am using silverlight

    http://www.programminghelp.com/dotnet/using-linq-to-xml-to-add-data-to-xml-file-in-c/


    Any pointers would help.

       private void Button_Click(object sender, RoutedEventArgs e)
            {

                StringBuilder sb = new StringBuilder();
                XmlWriterSettings xws = new XmlWriterSettings();
                xws.OmitXmlDeclaration = true;
                xws.Indent = true;




                using (XmlWriter xw = XmlWriter.Create(sb, xws))
                {
                    XDocument xmlDoc = XDocument.Load("Players.xml");
                    xmlDoc.Element("Players").Add(new XElement("Player", new XElement("Name", txtName.Text),
                new XElement("Team", txtTeam.Text)));

                    xmlDoc.Save(xw);
                }
            }
        }


    Friday, November 28, 2014 7:06 AM

Answers