Type Reason ArgumentException ws is null or string.Empty or contains non-white space characters. InvalidOperationException The XmlTextWriter.WriteState is WriteState.Closed.
In the dnprdnext release, the recommended practice is to create System.Xml.XmlWriter instances using the erload:System.Xml.XmlWriter.Create method and the System.Xml.XmlWriterSettings class. This allows you to take full advantage of all the new features introduced in this release. For more information, see Creating XML Writers.
This method is used to manually format your document. Use the XmlTextWriter.Formatting property to have the writer format the output automatically.