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

WriteDocType() public method

public WriteDocType ( string name, string pubid, string sysid, string subset ) : void
name string
pubid string
sysid string
subset string
return void
        public override void WriteDocType(string name, string pubid, string sysid, string subset) {
            try {
                ValidateName(name, false);

                AutoComplete(Token.Doctype);
                textWriter.Write("<!DOCTYPE ");
                textWriter.Write(name);
                if (pubid != null) {
                    textWriter.Write(" PUBLIC " + quoteChar);
                    textWriter.Write(pubid);
                    textWriter.Write(quoteChar + " " + quoteChar);
                    textWriter.Write(sysid);
                    textWriter.Write(quoteChar);
                }
                else if (sysid != null) {
                    textWriter.Write(" SYSTEM " + quoteChar);
                    textWriter.Write(sysid);
                    textWriter.Write(quoteChar);
                }
                if (subset != null) {
                    textWriter.Write("[");
                    textWriter.Write(subset);
                    textWriter.Write("]");
                }
                textWriter.Write('>');
            }
            catch {
                currentState = State.Error;
                throw;
            }
        }

Usage Example

Example #1
0
 public static void SaveAsXml(IEnumerable<Chapter> chapters, string path)
 {
     var writer = new XmlTextWriter(path, Encoding.GetEncoding("ISO-8859-1"));
     writer.Formatting = Formatting.Indented;
     writer.WriteStartDocument();
         writer.WriteDocType("Chapters", null, "matroskachapters.dtd", null);
         writer.WriteStartElement("Chapters");
             writer.WriteStartElement("EditionEntry");
             foreach (var chapter in chapters.Where(chapter => chapter.Keep))
             {
                 writer.WriteStartElement("ChapterAtom");
                     writer.WriteStartElement("ChapterTimeStart");
                         writer.WriteString(chapter.StartTimeXmlFormat); // 00:00:00.000
                     writer.WriteEndElement();
                     writer.WriteStartElement("ChapterDisplay");
                         writer.WriteStartElement("ChapterString");
                             writer.WriteString(chapter.Title); // Chapter 1
                         writer.WriteEndElement();
                         if (chapter.Language != null && chapter.Language != Language.Undetermined)
                         {
                             writer.WriteStartElement("ChapterLanguage");
                                 writer.WriteString(chapter.Language.ISO_639_2); // eng
                             writer.WriteEndElement();
                         }
                     writer.WriteEndElement();
                 writer.WriteEndElement();
             }
             writer.WriteEndElement();
         writer.WriteEndElement();
     writer.WriteEndDocument();
     writer.Close();
 }
All Usage Examples Of System.Xml.XmlTextWriter::WriteDocType