Indentation and new line command for XMLwriter in C#
I am writing some data to XML file...but when I open it all the values are in a single line...how can write it in readable format?ie each node in new line and indentation? FileStream fs = new FileStream("myfile.xml", FileMode.Create); XmlWriter w = XmlWriter.Create(fs); w.WriteStartDocument(); w.WriteStartElement("myfile"); w.WriteElementString("id", id.Text); w.WriteElementString("date", dateTimePicker1.Text); w.WriteElementString("version", ver.Text); w.WriteEndElement(); w.WriteEndDocument(); w.Flush(); fs.Close(); Use a XmlTextWriter instead of XmlWriter and then set the Indentation