How to write a string into a xml file on c#?

kinommanka

New Member
I've created a xml file using c#.\[code\]XmlTextWriter writer = new XmlTextWriter("Product.xml", System.Text.Encoding.UTF8);writer.WriteStartDocument(true);writer.Formatting = Formatting.Indented;writer.Indentation = 2;\[/code\]Then, I create my string:\[code\]string stringXML = string.Empty;stringXML = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><configurations xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"configurations.xsd\"><ProductsList><Product><ID>1</ID><Description>EPR</Description></Product></ProductsList></configurations>";\[/code\]Then I want to write my \[code\]stringXML\[/code\] into Product.xml file.I've tried : \[code\]System.IO.File.WriteAllText("Product.xml", stringXML);\[/code\] but it doesn't worked...How can I do this?
 
Back
Top