當前位置: 首頁>>代碼示例>>C#>>正文


C# XmlDocument.CreateDocumentType方法代碼示例

本文整理匯總了C#中System.Xml.XmlDocument.CreateDocumentType方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlDocument.CreateDocumentType方法的具體用法?C# XmlDocument.CreateDocumentType怎麽用?C# XmlDocument.CreateDocumentType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.XmlDocument的用法示例。


在下文中一共展示了XmlDocument.CreateDocumentType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SvgXmlBuilder

        // Provides methods for structuring xml to produce an Svg (nested in an HTML doc).
        public SvgXmlBuilder()
        {
            HtmlDoc = new XmlDocument ();

            // HTML-level
            HtmlDoc.AppendChild (HtmlDoc.CreateDocumentType ("html", "", "", ""));
            htmlDocElement = HtmlDoc.CreateElement ("html");

            // Body-level
            bodyElement = HtmlDoc.CreateElement ("body");
            htmlDocElement.AppendChild (bodyElement);

            // svg document
            SvgElement = HtmlDoc.CreateElement ("svg");
            bodyElement.AppendChild (SvgElement);
            var svgName = HtmlDoc.CreateAttribute ("name");
            svgName.Value = "Geographical Region Statistic Map";
            SvgElement.Attributes.Append (svgName);

            // Attributes independent of data.
            var heightAttr = HtmlDoc.CreateAttribute ("height");
            heightAttr.Value = "100%";
            var widthAttr = HtmlDoc.CreateAttribute ("width");
            widthAttr.Value = "100%";
            SvgElement.Attributes.Append (heightAttr);
            SvgElement.Attributes.Append (widthAttr);

            // TODO: Use css/jquery-style formatting?
            //new Style
            var svgColorAttr = HtmlDoc.CreateAttribute ("style");
            svgColorAttr.Value = "background:black";
            SvgElement.Attributes.Append (svgColorAttr);
        }
開發者ID:jasonstewartnz,項目名稱:UsStateVisualizer,代碼行數:34,代碼來源:SvgXmlBuilder.cs

示例2: Write

        internal static void Write(Stream stream, Dictionary<string, object> plist)
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.XmlResolver = null;

            XmlDeclaration xmlDecl = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", null);
            xmlDoc.AppendChild(xmlDecl);
            XmlDocumentType xmlDocType = xmlDoc.CreateDocumentType("plist", "-//Apple//DTD PLIST 1.0//EN", "http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);
            xmlDoc.AppendChild(xmlDocType);

            XmlElement rootElement = xmlDoc.CreateElement("plist");
            rootElement.SetAttribute("Version", "1.0");
            xmlDoc.AppendChild(rootElement);

            xmlDoc.DocumentElement.SetAttribute("Version", "1.0");

            rootElement.AppendChild(CreateNode(xmlDoc, plist));

            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;
            settings.Encoding = Encoding.UTF8;

            using (XmlWriter xw = XmlTextWriter.Create(stream, settings))
            {
                xmlDoc.Save(xw);
            }
        }
開發者ID:alexcmd,項目名稱:DiscUtils,代碼行數:27,代碼來源:Plist.cs

示例3: Render

 public void Render()
 {
     var xmlDocument = new XmlDocument();
     xmlDocument.AppendChild(xmlDocument.CreateDocumentType("html", null, null, null));
     htmlTag.RenderOn(xmlDocument);
     xmlDocument.Save(XmlWriter.Create(textWriter, new XmlWriterSettings { OmitXmlDeclaration = true }));
 }
開發者ID:Jestar342,項目名稱:htmlrenderer,代碼行數:7,代碼來源:HtmlRenderer.cs

示例4: ValidateDocument

 /// <summary>
 /// Validates the given xml document, throwing an exception if there
 /// is a validation failure
 /// </summary>
 /// <param name="xmlDocument">The xml document in a continuous 
 /// string</param>
 /// <param name="rootElementName">The root element name</param>
 /// <param name="dtd">The dtd path</param>
 /// <exception cref="InvalidXmlDefinitionException">Thrown if there
 /// is a validation failure</exception>
 public void ValidateDocument(string xmlDocument, string rootElementName, string dtd)
 {
     _xmlDocument = new XmlDocument();
     _xmlDocument.LoadXml(xmlDocument);
     _xmlDocument.InsertBefore(_xmlDocument.CreateDocumentType(rootElementName, null, null, dtd),
                                 _xmlDocument.DocumentElement);
     ValidateCurrentDocument();
 }
開發者ID:kevinbosman,項目名稱:habanero,代碼行數:18,代碼來源:XmlDocumentValidator.cs

示例5: CreateHtmlArticle

    public static XmlElement CreateHtmlArticle(string title)
    {
      title += " – SimpleDLNA";

      var document = new XmlDocument();
      document.AppendChild(document.CreateDocumentType(
        "html", null, null, null));

      document.AppendChild(document.EL("html"));

      var head = document.EL("head");
      document.DocumentElement.AppendChild(head);
      head.AppendChild(document.EL("title", text: title));
      head.AppendChild(document.EL(
        "link",
        new AttributeCollection() {
          { "rel", "stylesheet" },
          { "type", "text/css" },
          { "href", "/static/browse.css" }
        }
        ));

      var body = document.EL("body");
      document.DocumentElement.AppendChild(body);

      var article = document.EL("article");
      body.AppendChild(article);

      var header = document.EL("header");
      header.AppendChild(document.EL("h1", text: title));
      article.AppendChild(header);

      var footer = document.EL("footer");
      footer.AppendChild(document.EL(
        "img",
        new AttributeCollection() { { "src", "/icon/smallPNG" } }
        ));
      footer.AppendChild(document.EL("h3", text: string.Format(
        "SimpleDLNA Media Server: sdlna/{0}.{1}",
        Assembly.GetExecutingAssembly().GetName().Version.Major,
        Assembly.GetExecutingAssembly().GetName().Version.Minor
        )));
      footer.AppendChild(document.EL(
        "p",
        new AttributeCollection() { { "class", "desc" } },
        "A simple, zero-config DLNA media server, that you can just fire up and be done with it."
        ));
      footer.AppendChild(document.EL("a",
        new AttributeCollection() {
          { "href", "https://github.com/nmaier/simpleDLNA/" }
        },
        "Fork me on GitHub"
        ));
      body.AppendChild(footer);

      return article;
    }
開發者ID:modulexcite,項目名稱:simpleDLNA,代碼行數:57,代碼來源:HtmlTools.cs

示例6: XslExportTransform

		public static XmlDocument XslExportTransform (XmlDocument doc)
		{
			XmlReader reader = Registry.GladeExportXsl.Transform (doc, null, (XmlResolver)null);
			doc = new XmlDocument ();
			doc.PreserveWhitespace = true;
			doc.Load (reader);

			XmlDocumentType doctype = doc.CreateDocumentType ("glade-interface", null, Glade20SystemId, null);
			doc.PrependChild (doctype);

			return doc;
		}
開發者ID:RainsSoft,項目名稱:playscript-monodevelop,代碼行數:12,代碼來源:GladeUtils.cs

示例7: CreatePlist

        public static XmlNode CreatePlist(XmlDocument doc)
        {
            XmlDeclaration xmldecl = doc.CreateXmlDeclaration("1.0", "utf-8", null);
            doc.AppendChild(xmldecl);
            XmlDocumentType docType = doc.CreateDocumentType("plist", "-//Apple Computer//DTD PLIST 1.0//EN", "http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);
            doc.AppendChild(docType);

            XmlNode xml_plist = XMLOpt.CreateNode(doc, doc, "plist", null);
            XmlAttribute plistVersion = doc.CreateAttribute("version");
            plistVersion.Value = "1.0";
            xml_plist.Attributes.Append(plistVersion);
            return xml_plist;
        }
開發者ID:AndrewFanChina,項目名稱:Cyclone2D-Editor,代碼行數:13,代碼來源:XMLOpt.cs

示例8: CreateDocument

        public XmlDocument CreateDocument()
        {
            // <?xeditnet-profile ../xenwebprofile/bin/debug/xenwebprofile.dll!XenWebProfile.ProfileImpl?>

            XmlDocument doc=new XmlDocument();
            XmlDocumentType doctype=doc.CreateDocumentType(profileInfo.Root, profileInfo.PublicId, profileInfo.SystemId, null);
            XmlElement root=doc.CreateElement(profileInfo.Root);
            XmlProcessingInstruction pi=doc.CreateProcessingInstruction("xeditnet-profile", profileInfo.Profile);

            doc.AppendChild(doctype);
            doc.AppendChild(pi);
            doc.AppendChild(root);
            return doc;
        }
開發者ID:jugglingcats,項目名稱:XEditNet,代碼行數:14,代碼來源:RegisteredTypeDefaultWizard.cs

示例9: XslExportTransform

		public static XmlDocument XslExportTransform (XmlDocument doc)
		{
			StringWriter sw = new StringWriter ();
			XmlWriter xw = XmlWriter.Create (sw);
			Registry.GladeExportXsl.Transform (doc, xw);
			XmlReader reader = XmlReader.Create (sw.ToString ());
			doc = new XmlDocument ();
			doc.PreserveWhitespace = true;
			doc.Load (reader);

			XmlDocumentType doctype = doc.CreateDocumentType ("glade-interface", null, Glade20SystemId, null);
			doc.PrependChild (doctype);

			return doc;
		}
開發者ID:Kalnor,項目名稱:monodevelop,代碼行數:15,代碼來源:GladeUtils.cs

示例10: NewDocument

 public static dom4cs NewDocument(String vRootTag, String vEncoding, String vDTDFileName) {
   dom4cs newDOM4CS = new dom4cs();
   XmlDocument doc = new XmlDocument();
   if (vEncoding != null)
     newDOM4CS.FEncoding = vEncoding;
   XmlDeclaration xd = doc.CreateXmlDeclaration("1.0", newDOM4CS.FEncoding, null);
   doc.AppendChild(xd);
   if (vDTDFileName != null) {
     XmlDocumentType xdt = doc.CreateDocumentType(vRootTag, null, vDTDFileName, null);
     doc.AppendChild(xdt);
   }
   if (vRootTag != null) {
     XmlElement rn = doc.CreateElement(vRootTag);
     doc.AppendChild(rn);
   }
   newDOM4CS.XmlDoc = doc;
   return newDOM4CS;
 }
開發者ID:tormoz70,項目名稱:Bio.Framework.8,代碼行數:18,代碼來源:dom4cs.cs

示例11: InitConfigXml

 private void InitConfigXml()
 {
     ConfigXml = new XmlDocument();
     XmlDeclaration decl = ConfigXml.CreateXmlDeclaration("1.0", "GBK", "yes");
     ConfigXml.AppendChild(decl);
     XmlDocumentType doctype = ConfigXml.CreateDocumentType("root", null, null, "<!ELEMENT Station ANY><!ATTLIST Station SSN ID #REQUIRED>");
     ConfigXml.AppendChild(doctype);
     RootNode = ConfigXml.CreateElement("MapConfig");
     ConfigXml.AppendChild(RootNode);
     XmlNode node = ConfigXml.CreateElement("Map");
     RootNode.AppendChild(node);
     node = ConfigXml.CreateElement("Divs");
     RootNode.AppendChild(node);
     node = ConfigXml.CreateElement("Statics");
     RootNode.AppendChild(node);
     node = ConfigXml.CreateElement("Stations");
     RootNode.AppendChild(node);
     node = ConfigXml.CreateElement("Words");
     RootNode.AppendChild(node);
 }
開發者ID:ZoeCheck,項目名稱:128_5.6_2010,代碼行數:20,代碼來源:FrmDCreateConfig.cs

示例12: WriteRepository

        public static XmlDocument WriteRepository(ICurricularUnitFormRepository<CurricularUnitForm> cufr)
        {
            XmlDocument xmlFile = new XmlDocument();
            XmlDeclaration decl = xmlFile.CreateXmlDeclaration("1.0", "utf-8", null);
            xmlFile.InsertBefore(decl, xmlFile.DocumentElement);

            XmlDocumentType type = xmlFile.CreateDocumentType("fuc-repository", "template.dtd", null, null);
            xmlFile.AppendChild(type);
            XmlElement fuc_repo = xmlFile.CreateElement("fuc-repository");
            fuc_repo.SetAttribute("school", "Instituto Superior de Engenharia de Lisboa");
            fuc_repo.SetAttribute("language", "pt");
            xmlFile.AppendChild(fuc_repo);

            foreach (CurricularUnitForm cuf in cufr.GetAll())
            {
                /*http://stackoverflow.com/questions/982597/what-is-the-fastest-way-to-combine-two-xml-files-into-one*/
                var xmlTmp = xmlFile.ImportNode(Write(cuf, false).DocumentElement, true);
                fuc_repo.AppendChild(xmlTmp);
            }
            return xmlFile;
        }
開發者ID:isel-31401,項目名稱:ISEL-LEIC-PI-31401,代碼行數:21,代碼來源:CurricularUnitFormWriter.cs

示例13: DataWithPropertyList

        public static byte[] DataWithPropertyList(Dictionary<string, object> plist)
        {
            XmlDocument doc = new XmlDocument();
            doc.XmlResolver = new PlistDTDResolver();

            doc.AppendChild(doc.CreateXmlDeclaration("1.0", "UTF-8", null));
            doc.AppendChild(doc.CreateDocumentType("plist",
                                                            "-//Apple Computer/DTD PLIST 1.0//EN",
                                                            "http://www.apple.com/DTDs/PropertyList-1.0.dtd", null));

            XmlElement root = doc.CreateElement("plist");
            root.SetAttribute("version", "1.0");

            ArrayList plistNodes = plist.PropertyListRepresentationWithKey(doc, null);
            foreach (XmlElement el in plistNodes) {
                root.AppendChild(el);
            }

            doc.AppendChild(root);

            MemoryStream stream = new MemoryStream();
            doc.Save(stream);
            return stream.ToArray();
        }
開發者ID:klm1,項目名稱:SparkleDotNET,代碼行數:24,代碼來源:KNPropertyListSerialization.cs

示例14: ReGenerateSchema

        protected static void ReGenerateSchema(XmlDocument xmlDoc)
        {
            string dtd = DocumentType.GenerateXmlDocumentType();

            // remove current doctype
            XmlNode n = xmlDoc.FirstChild;
            while (n.NodeType != XmlNodeType.DocumentType && n.NextSibling != null)
            {
                n = n.NextSibling;
            }
            if (n.NodeType == XmlNodeType.DocumentType)
            {
                xmlDoc.RemoveChild(n);
            }
            XmlDocumentType docType = xmlDoc.CreateDocumentType("root", null, null, dtd);
            xmlDoc.InsertAfter(docType, xmlDoc.FirstChild);
        }
開發者ID:elrute,項目名稱:Triphulcas,代碼行數:17,代碼來源:content.cs

示例15: ValidateSchema

        protected static XmlDocument ValidateSchema(string docTypeAlias, XmlDocument xmlDoc)
        {
			// check if doctype is defined in schema else add it
			// can't edit the doctype of an xml document, must create a new document

			var doctype = xmlDoc.DocumentType;
			var subset = doctype.InternalSubset;
			if (!subset.Contains(string.Format("<!ATTLIST {0} id ID #REQUIRED>", docTypeAlias)))
			{
				subset = string.Format("<!ELEMENT {0} ANY>\r\n<!ATTLIST {0} id ID #REQUIRED>\r\n{1}", docTypeAlias, subset);
				var xmlDoc2 = new XmlDocument();
				doctype = xmlDoc2.CreateDocumentType("root", null, null, subset);
				xmlDoc2.AppendChild(doctype);
				var root = xmlDoc2.ImportNode(xmlDoc.DocumentElement, true);
				xmlDoc2.AppendChild(root);

				// apply
				xmlDoc = xmlDoc2;
			}

			return xmlDoc;
        }
開發者ID:elrute,項目名稱:Triphulcas,代碼行數:22,代碼來源:content.cs


注:本文中的System.Xml.XmlDocument.CreateDocumentType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。