System.Xml.XmlTextWriter.WriteWhitespace C# (CSharp) Method

WriteWhitespace() public method

public WriteWhitespace ( string ws ) : void
ws string
return void
        public override void WriteWhitespace(string ws) {
            try {
                if (null == ws || ws.Length == 0) {
                    throw new ArgumentException(Res.GetString(Res.Xml_NonWhitespace));
                }

                if (!xmlCharType.IsOnlyWhitespace(ws)) {
                    throw new ArgumentException(Res.GetString(Res.Xml_NonWhitespace));
                }
                AutoComplete(Token.Whitespace);
                xmlEncoder.Write(ws);
            }
            catch {
                currentState = State.Error;
                throw;
            }
        }

Usage Example

Example #1
0
        static void ExportXMLfile(string XMLfile)
        {
            string filename = XMLfile;

            try
            {
                File.Delete(XMLfile);
            }
            catch
            {
            //        Console.Write(".X2." + XMLfile + ".");
            }

            XmlTextWriter xml = null;

            xml = new XmlTextWriter(filename, null);

            xml.WriteStartDocument();
            xml.WriteStartElement("Features");
            xml.WriteWhitespace("\n");
            xml.WriteElementString("Score", GlobalVar.myScore.ToString());
            xml.WriteWhitespace("\n  ");

            xml.WriteEndElement();
            xml.WriteWhitespace("\n");

            xml.WriteEndDocument();

            //Write the XML to file and close the writer.
            xml.Flush();
            xml.Close();
        }
All Usage Examples Of System.Xml.XmlTextWriter::WriteWhitespace