System.Xml.XmlDocument.CreateXmlDeclaration C# (CSharp) Method

CreateXmlDeclaration() public method

public CreateXmlDeclaration ( String version, string encoding, string standalone ) : XmlDeclaration
version String
encoding string
standalone string
return XmlDeclaration
        public virtual XmlDeclaration CreateXmlDeclaration(String version, string encoding, string standalone)
        {
            return new XmlDeclaration(version, encoding, standalone, this);
        }

Usage Example

Example #1
0
        void Save()
        {
            var doc            = new System.Xml.XmlDocument();
            var xmlDeclaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
            var root           = doc.DocumentElement;

            doc.InsertBefore(xmlDeclaration, root);
            var records = doc.CreateElement("records");

            doc.AppendChild(records);
            var tables        = doc.CreateElement(string.Empty, "tables", string.Empty);
            var singleRecords = doc.CreateElement(string.Empty, "srec", string.Empty);
            var teamRecords   = doc.CreateElement(string.Empty, "trec", string.Empty);

            records.AppendChild(singleRecords);
            records.AppendChild(teamRecords);
            records.AppendChild(tables);

            // single records:
            foreach (var s in this.mSingleStorage)
            {
                var r     = doc.CreateElement(string.Empty, "record", string.Empty);
                var dsvId = doc.CreateAttribute("id");
                dsvId.Value = s.SwimmerId;
                r.Attributes.Append(dsvId);
            }
        }
All Usage Examples Of System.Xml.XmlDocument::CreateXmlDeclaration