I am having problems with the Create method in XmlWriter.
Even when I use the example from msdn, it will not work.
http://msdn.microsoft.com/en-us/library/kcsse48t.aspx
I created a Blank Page project for a Windows Store app. In it, ive inserted example code from msdn to test how the XmlWriter class works.
VS gives me an error:
Cannot resolve method 'Create(string)', candidates are:
System.Xml.XmlWriter Create(System.IO.Stream) (in class XmlWriter)
System.Xml.XmlWriter Create(System.IO.TextWriter) (in class XmlWriter)
System.Xml.XmlWriter Create(System.Text.StringBuilder) (in class XmlWriter)
System.Xml.XmlWriter Create(System.Xml.XmlWriter) (in class XmlWriter)
This works without problems in a console application. But I need to make an application for the Windows store.
What I want to do is add to the existing xml file.
Can someone tell me why this does not work or how to achieve my goal differently.
Thank you for your time.
EDIT:
Sorry, my code is:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Xml;
using System.Xml.Linq;
using Windows.Data.Xml.Dom;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
namespace DatabaseTest
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
private void button_submit_Click(object sender, RoutedEventArgs e)
{
using (XmlWriter writer = XmlWriter.Create("output.xml"))
{
writer.WriteStartElement("book");
writer.WriteElementString("price", "19.95");
writer.WriteEndElement();
writer.Flush();
}
}
}
}