Пример #1
0
        public void Write(Mml mml, string filename)
        {
            mml.SetSupplementData();

            var doc = CreateXmlDocument();

            var def = doc.CreateXmlDeclaration("1.0", "UTF-8", null);

            doc.AppendChild(def);

            var mmlnode = doc.CreateElement("Mml");

            XmlAttribute attr = doc.CreateAttribute("version");

            attr.Value = mml.Version;
            mmlnode.Attributes.Append(attr);

            attr       = doc.CreateAttribute("createDate");
            attr.Value = mml.CreateDate.ToString("yyyy-MM-ddThh:mm:ss");
            mmlnode.Attributes.Append(attr);

            doc.AppendChild(mmlnode);

            doc = AddMmlXmlNamespaces(doc);

            mmlnode.AppendChild(mml.Header.WriteXml(doc));

            mmlnode.AppendChild(mml.Body.WriteXml(doc));

            doc.Validate(new ValidationEventHandler(ValidationEventHandler));
            using (XmlWriter writer = XmlWriter.Create(filename)) {
                doc.Save(writer);
            }
        }