How to write Newlines in XmlDocument
-
I'm trying to write a XmlDocument like so:
XmlDocument doc = new XmlDocument(); // Xml is added StreamWriter s = new StreamWriter("output.xml"); XmlTextWriter w = new XmlTextWriter(s); doc.WriteContentTo (w); w.Flush(); s.Flush(); s.WriteLine(); s.Close();
But it writes all the xml on one line. How do I make it put each node on its own line? -
I'm trying to write a XmlDocument like so:
XmlDocument doc = new XmlDocument(); // Xml is added StreamWriter s = new StreamWriter("output.xml"); XmlTextWriter w = new XmlTextWriter(s); doc.WriteContentTo (w); w.Flush(); s.Flush(); s.WriteLine(); s.Close();
But it writes all the xml on one line. How do I make it put each node on its own line?Could try the Formatting property of the XmlTextWriter.
Proud to have finally moved to the A-Ark. Which one are you in? Developer, Author (Guardians of Xen)
-
Could try the Formatting property of the XmlTextWriter.
Proud to have finally moved to the A-Ark. Which one are you in? Developer, Author (Guardians of Xen)
-
I'm trying to write a XmlDocument like so:
XmlDocument doc = new XmlDocument(); // Xml is added StreamWriter s = new StreamWriter("output.xml"); XmlTextWriter w = new XmlTextWriter(s); doc.WriteContentTo (w); w.Flush(); s.Flush(); s.WriteLine(); s.Close();
But it writes all the xml on one line. How do I make it put each node on its own line?Enable indenting?