I am making an application in a Windows repository and have a problem writing xml in the generated XML file. I did this XML file editing in the Windows Store application , but it did not work for me.
I want this xml to be written in my xml file at the click of a button.
Any alternative method for this material.
<drink> <drinkImage>ck.png</drinkImage> <drinkTitle>COKE</drinkTitle> <drinkDescription>(1793-1844)</drinkDescription> </drink>
My current file is:
<?xml version="1.0" encoding="utf-8" ?> <drinks> <drink> <drinkImage>pepsi.png</drinkImage> <drinkTitle>PEPSI</drinkTitle> <drinkDescription>(1793-1844)</drinkDescription> </drink> **<here I Want above xml on button click>** </drinks>
Here is what I tried:
namespace DrinksApp { /// <summary> /// An empty page that can be used on its own or navigated to within a Frame. /// </summary> public sealed partial class coke : Page { public coke() { this.InitializeComponent(); } XmlDocument dom = new XmlDocument(); private void Button_Click(object sender, RoutedEventArgs e) { this.Frame.Navigate(typeof(softdrinks)); } private async void Button_Click_1(object sender, RoutedEventArgs e) { XDocument xmlDoc = XDocument.Load("favourite//fav.xml"); xmlDoc.Root.Add(new XElement("drink", new XAttribute("drinkImage","ck.png"), new XAttribute("drinkTitle","PEPSI"), new XAttribute("drinkDescription","NONE") )); xmlDoc.Save(xmlDoc); **//This isn't working in windows store ..** } } } }
I already have an xml file as above: 
c # xml windows-store-apps xmldocument
mohammad haris
source share