当前位置: 首页>>代码示例>>C#>>正文


C# XmlDocument.CreateXmlDeclaration方法代码示例

本文整理汇总了C#中System.Xml.XmlDocument.CreateXmlDeclaration方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDocument.CreateXmlDeclaration方法的具体用法?C# XmlDocument.CreateXmlDeclaration怎么用?C# XmlDocument.CreateXmlDeclaration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XmlDocument的用法示例。


在下文中一共展示了XmlDocument.CreateXmlDeclaration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateXMLDocument

        public static XmlDocument CreateXMLDocument()
        {
            XmlDocument doc = new XmlDocument();
            XmlNode docNode = doc.CreateXmlDeclaration("1.0", null, null);
            doc.AppendChild(docNode);

            XmlNode configurationNode = doc.CreateElement("Configuration");
            doc.AppendChild(configurationNode);

            XmlNode hostNode = doc.CreateNode(XmlNodeType.Element, "host", "");
            hostNode.InnerText = "https://testserver.datacash.com/Transaction";
            XmlNode timeoutNode = doc.CreateNode(XmlNodeType.Element, "timeout", "");
            timeoutNode.InnerText = "500";
            XmlNode proxyNode = doc.CreateNode(XmlNodeType.Element, "proxy", "");
            proxyNode.InnerText = "http://bloxx.dfguk.com:8080";
            XmlNode logfileNode = doc.CreateNode(XmlNodeType.Element, "logfile", "");
            logfileNode.InnerText = @"C:\Inetpub\wwwroot\WSDataCash\log.txt";
            XmlNode loggingNode = doc.CreateNode(XmlNodeType.Element, "logging", "");
            loggingNode.InnerText = "1";

            configurationNode.AppendChild(hostNode);
            configurationNode.AppendChild(timeoutNode);
            configurationNode.AppendChild(proxyNode);
            configurationNode.AppendChild(logfileNode);
            configurationNode.AppendChild(loggingNode);

            return doc;
        }
开发者ID:radicalgeek,项目名称:UpdateConfigCustomAction,代码行数:28,代码来源:CreateXMLFile.cs

示例2: InvokeResponse

        public string InvokeResponse(string funcName, List<UPnPArg> args)
        {
            XmlDocument doc = new XmlDocument();
            XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null);
            doc.AppendChild(dec);

            XmlElement env = doc.CreateElement("s", "Envelope", "http://schemas.xmlsoap.org/soap/envelope/");
            doc.AppendChild(env);
            env.SetAttribute("encodingStyle", "http://schemas.xmlsoap.org/soap/envelope/", "http://schemas.xmlsoap.org/soap/encoding/");

            XmlElement body = doc.CreateElement("Body", "http://schemas.xmlsoap.org/soap/envelope/");
            body.Prefix = "s";
            env.AppendChild(body);

            XmlElement func = doc.CreateElement("u", funcName + "Response", "urn:schemas-upnp-org:service:AVTransport:1");
            body.AppendChild(func);
            func.SetAttribute("xmlns:u", "urn:schemas-upnp-org:service:AVTransport:1");

            if (args != null)
            {
                foreach (UPnPArg s in args)
                {
                    XmlElement f = doc.CreateElement(s.ArgName);
                    func.AppendChild(f);
                    f.InnerText = s.ArgVal;
                }
            }

            //Saved for debugging:
            doc.Save(@"InvokeResponse.xml");

            string msg = AppendHead(doc.OuterXml);
            return msg;
        }
开发者ID:GufCab,项目名称:Semester-Projekt---Pi-Program,代码行数:34,代码来源:InvokeResponseGen.cs

示例3: CreateXML

        XmlDocument CreateXML(string result, Track[] items = null)
        {
            XmlDocument xmldoc = new XmlDocument();
            XmlDeclaration decl = xmldoc.CreateXmlDeclaration("1.0", "utf-8", null);
            xmldoc.AppendChild(decl);
            XmlNode root = xmldoc.CreateElement("HttpResponse");
            xmldoc.AppendChild(root);
            XmlNode res = xmldoc.CreateElement("Result");
            res.InnerText = result;
            root.AppendChild(res);
            XmlNode args = xmldoc.CreateElement("Params");
            root.AppendChild(args);
            if (items!=null)
            {
                for (int i = 0; i < items.Length; i++)
                {
                    XmlNode node = xmldoc.CreateElement("Song");
                    args.AppendChild(node);

                    XmlNode name = xmldoc.CreateElement("Name");
                    name.InnerText = items[i].Name;
                    XmlNode title = xmldoc.CreateElement("Title");
                    title.InnerText = items[i].Title;
                    XmlNode filestream = xmldoc.CreateElement("FileStream");
                    filestream.InnerText = items[i].FileStream;

                    node.AppendChild(name);
                    node.AppendChild(title);
                    node.AppendChild(filestream);
                }
            }
            return xmldoc;
        }
开发者ID:yanatokareva01,项目名称:ITMO,代码行数:33,代码来源:Program.cs

示例4: CreateXml

        public void CreateXml(string xmlPath, string xmlName, string[] value, string[] xmlElementNode)
        {
            try
            {
                string str = inType.ToString();
                if (str.Length < 5)
                {
                    return;
                }
                string rootName = str.Substring(str.Length - 5, 4);
                XmlDocument doc = new XmlDocument();
                XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
                doc.AppendChild(dec);

                XmlElement root = doc.CreateElement(rootName);
                doc.AppendChild(root);
                XmlNode childElement = doc.CreateElement(str);
                for (int i = 0; i < xmlElementNode.Length; i++)
                {
                    XmlElement xe = doc.CreateElement(xmlElementNode[i]);
                    xe.InnerText = value[i];
                    childElement.AppendChild(xe);
                }
                root.AppendChild(childElement);
                doc.Save(string.Concat(@"", xmlPath, xmlName));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
开发者ID:carriercomm,项目名称:BillingSystem,代码行数:31,代码来源:OperateXml.cs

示例5: btn_OK_Click

        private void btn_OK_Click(object sender, EventArgs e)
        {
            XmlDocument xmlDoc = new XmlDocument();
            XmlNode docNode = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", null);
            xmlDoc.AppendChild(docNode);

            XmlNode version = xmlDoc.CreateElement("version");
            xmlDoc.AppendChild(version);

            XmlNode sbtNode = xmlDoc.CreateElement("SBT");
            XmlAttribute sbtAttribute = xmlDoc.CreateAttribute("Path");
            sbtAttribute.Value = textBox1.Text;
            sbtNode.Attributes.Append(sbtAttribute);
            version.AppendChild(sbtNode);

            XmlNode garenaNode = xmlDoc.CreateElement("Garena");
            XmlAttribute garenaAttribute = xmlDoc.CreateAttribute("Path");
            garenaAttribute.Value = textBox2.Text;
            garenaNode.Attributes.Append(garenaAttribute);
            version.AppendChild(garenaNode);

            XmlNode superNode = xmlDoc.CreateElement("Super");
            XmlAttribute superAttribute = xmlDoc.CreateAttribute("Path");
            superAttribute.Value = textBox3.Text;
            superNode.Attributes.Append(superAttribute);
            version.AppendChild(superNode);

            xmlDoc.Save("path");
            this.Close();
        }
开发者ID:nghuuhieu1994,项目名称:HoNAvatarVersionManager,代码行数:30,代码来源:ChangePath.cs

示例6: BuildTreeNodes

        public static TreeNodeCollection BuildTreeNodes(bool refreshSiteMap)
        {
            XmlDocument map = null;
            XmlElement root = null;
            XmlElement examplesNode = null;

            if (refreshSiteMap)
            {
                map = new XmlDocument();
                XmlDeclaration dec = map.CreateXmlDeclaration("1.0", "utf-8", null);
                map.AppendChild(dec);

                root = map.CreateElement("siteMap");
                root.SetAttribute("xmlns", "http://schemas.microsoft.com/AspNet/SiteMap-File-1.0");
                map.AppendChild(root);

                examplesNode = map.CreateElement("siteMapNode");
                examplesNode.SetAttribute("title", "Examples");
                root.AppendChild(examplesNode);
            }

            string path = HttpContext.Current.Server.MapPath("~/Examples/");
            TreeNodeCollection result = BuildTreeLevel(new DirectoryInfo(path), 1, 3, examplesNode);

            if (root != null && root.ChildNodes.Count > 0)
            {
                map.Save(HttpContext.Current.Server.MapPath("Web.sitemap"));
            }

            return result;
        }
开发者ID:pgodwin,项目名称:Ext.net,代码行数:31,代码来源:UIHelpers.cs

示例7: GenerateForGenerateSolution

        public XmlDocument GenerateForGenerateSolution(string platform, IEnumerable<XmlElement> projectElements)
        {
            var doc = new XmlDocument();
            doc.AppendChild(doc.CreateXmlDeclaration("1.0", "UTF-8", null));
            var input = doc.CreateElement("Input");
            doc.AppendChild(input);

            var generation = doc.CreateElement("Generation");
            var platformName = doc.CreateElement("Platform");
            platformName.AppendChild(doc.CreateTextNode(platform));
            var hostPlatformName = doc.CreateElement("HostPlatform");
            hostPlatformName.AppendChild(doc.CreateTextNode(_hostPlatformDetector.DetectPlatform()));
            generation.AppendChild(platformName);
            generation.AppendChild(hostPlatformName);
            input.AppendChild(generation);

            var featuresNode = doc.CreateElement("Features");
            foreach (var feature in _featureManager.GetAllEnabledFeatures())
            {
                var featureNode = doc.CreateElement(feature.ToString());
                featureNode.AppendChild(doc.CreateTextNode("True"));
                featuresNode.AppendChild(featureNode);
            }
            input.AppendChild(featuresNode);

            var projects = doc.CreateElement("Projects");
            input.AppendChild(projects);

            foreach (var projectElem in projectElements)
            {
                projects.AppendChild(doc.ImportNode(projectElem, true));
            }

            return doc;
        }
开发者ID:marler8997,项目名称:Protobuild,代码行数:35,代码来源:SolutionInputGenerator.cs

示例8: _processDocument

        private static void _processDocument(XmlNode document, StreamWriter sw)
        {
            XmlDocument docNode = new XmlDocument();
            XmlDeclaration xmlDeclaration = docNode.CreateXmlDeclaration("1.0", "cp866", null);
            docNode.InsertBefore(xmlDeclaration, docNode.DocumentElement);

            XmlElement docRoot = (XmlElement)docNode.ImportNode(document, true);
            docNode.AppendChild(docRoot);

            Regex rgx = new Regex("<(\\w+)>");

            String s = rgx.Replace(docNode.OuterXml, "<$1 xmlns=\"itek\">");
            s = s.Replace("<Документ xmlns=\"itek\">", "<Документ>");
            s = s.Replace("РаботыЧужие", "true");

            eurocarService.Документ documentRequest = (eurocarService.Документ)_x.Deserialize(new System.IO.StringReader(s));

            try
            {
                sw.WriteLine(DateTime.Now.ToString() + " Отправка документа " + documentRequest.Номер);
                _cl.PutDoc(documentRequest);
            }
            catch (ProtocolException e)
            {
                // Silently except it...
            }
        }
开发者ID:eur00t,项目名称:atlant.xml2SOAP,代码行数:27,代码来源:FilesProcessor.cs

示例9: AddAttachmentPlaceHolder

        public void AddAttachmentPlaceHolder(string actualPath, string placeholderPath)
        {
            var placeholderDocument = new XmlDocument();

			placeholderDocument.CreateXmlDeclaration("1.0", "utf-16", "yes");

            XmlNode rootNode = placeholderDocument.CreateNode(XmlNodeType.Element, "ManagedAttachment", string.Empty);
            XmlNode actualPathNode = placeholderDocument.CreateNode(XmlNodeType.Element, "ActualPath", string.Empty);
            XmlNode placeholderNode = placeholderDocument.CreateNode(XmlNodeType.Element, "PlaceholderPath",
                                                                     string.Empty);

            actualPathNode.InnerText = actualPath;
            placeholderNode.InnerText = placeholderPath;

            rootNode.AppendChild(actualPathNode);
            rootNode.AppendChild(placeholderNode);

            placeholderDocument.AppendChild(rootNode);

            using (var ms = new MemoryStream())
            {
                ms.Position = 0;
                placeholderDocument.Save(ms);
                ms.Flush();

                ms.Position = 0;
                var sr = new StreamReader(ms);
                string xml = sr.ReadToEnd();

                string filecontents = LargeAttachmentHelper.FileTag + xml;
				File.WriteAllText(placeholderPath, filecontents, Encoding.Unicode);
            }
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:33,代码来源:BigAttachmentsManager.cs

示例10: Save

 public void Save(string fileName)
 {
     XmlDocument doc = new XmlDocument();
     XmlNode declNode = doc.CreateXmlDeclaration("1.0", "utf-8", null);
     doc.AppendChild(declNode);
     var regNode = doc.CreateElement(@"Реестр");
     doc.AppendChild(regNode);
     var packNode = doc.CreateElement(@"Пакет");
     regNode.AppendChild(packNode);
     var recipNode = doc.CreateElement(@"Получатель");
     recipNode.SetAttribute("ИНН", RecipientINN);
     recipNode.SetAttribute("КПП", RecipientKPP);
     packNode.AppendChild(recipNode);
     var sendNode = doc.CreateElement(@"Отправитель");
     sendNode.SetAttribute("ИНН", SenderINN);
     sendNode.SetAttribute("КПП", SenderKPP);
     packNode.AppendChild(sendNode);
     foreach (var attachment in _Attachments)
     {
         var attNode = doc.CreateElement(@"Вложение");
         attNode.SetAttribute("ИмяФайла", attachment);
         packNode.AppendChild(attNode);
     }
     doc.Save(fileName);
 }
开发者ID:kurilovigor,项目名称:snt,代码行数:25,代码来源:Package.cs

示例11: TraceToXML

        public TraceToXML(Point beginPoint, String penColor, String penWidth)
        {
            this.beginPoint = beginPoint;
            //创建 XML 对象
            xmlDocument = new XmlDocument();
            //声明 XML
            xmlDeclare = xmlDocument.CreateXmlDeclaration("1.0", "utf-8", null);
            //创建根节点
            elementRoot = xmlDocument.CreateElement("Trace");
            xmlDocument.AppendChild(elementRoot);

            //创建第一个节点
            //创建节点 Section
            elementSection = xmlDocument.CreateElement("Section");
            elementSection.SetAttribute("penColor", penColor);
            elementSection.SetAttribute("penWidth", penWidth);
            elementRoot.AppendChild(elementSection);
            //创建 Section 的子节点 Point
            XmlElement elementPoint = xmlDocument.CreateElement("Point");
            elementPoint.SetAttribute("time", "0");
            XmlElement elementX = xmlDocument.CreateElement("X");
            elementX.InnerText = beginPoint.X.ToString();
            elementPoint.AppendChild(elementX);
            XmlElement elementY = xmlDocument.CreateElement("Y");
            elementY.InnerText = beginPoint.Y.ToString();
            elementPoint.AppendChild(elementY);
            elementSection.AppendChild(elementPoint);
        }
开发者ID:zlmoment,项目名称:DrawSthCSharp,代码行数:28,代码来源:TraceToXML.cs

示例12: getXmlDoc

 private static XmlDocument getXmlDoc()
 {
     XmlDocument xmlDoc;
     try
     {
         xmlDoc = new XmlDocument();
         xmlDoc.Load(CONFIG_PATH);
     }
     catch
     {
         string dest = DateTime.Now.ToFileTime().ToString();
         if (File.Exists(CONFIG_PATH))
         {
             File.Move(CONFIG_PATH, dest);
             MessageBox.Show("配置已损坏!将使用默认配置\n原配置文件已被重命名为" + dest, "警告");
         }
         xmlDoc = new XmlDocument();
         xmlDoc.CreateXmlDeclaration("1.0", "utf-8", "yes");
         XmlNode root = xmlDoc.CreateElement("config");
         XmlNode defaultPath = xmlDoc.CreateElement("path");
         XmlCDataSection cdata = xmlDoc.CreateCDataSection(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
         defaultPath.AppendChild(cdata);
         root.AppendChild(defaultPath);
         xmlDoc.AppendChild(root);
     }
     return xmlDoc;
 }
开发者ID:C4211,项目名称:GI,代码行数:27,代码来源:UserConfigUtil.cs

示例13: CreateBasicRssDoc

        private void CreateBasicRssDoc(XmlDocument doc, string title, string description, string link)
        {
            XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "utf-8", null);
            doc.InsertBefore(declaration, doc.DocumentElement);

            XmlElement rssNode = doc.CreateElement("rss");
            XmlAttribute rssAtt = doc.CreateAttribute("version");
            rssAtt.Value = "2.0";
            rssNode.Attributes.Append(rssAtt);

            XmlElement channelNode = doc.CreateElement("channel");

            XmlElement titleNode = doc.CreateElement("title");
            titleNode.InnerText = title;
            channelNode.AppendChild(titleNode);

            XmlElement desNode = doc.CreateElement("description");
            desNode.InnerText = description;
            channelNode.AppendChild(desNode);

            XmlElement linkNode = doc.CreateElement("link");
            linkNode.InnerText = link;
            channelNode.AppendChild(linkNode);

            rssNode.AppendChild(channelNode);
            doc.AppendChild(rssNode);
        }
开发者ID:ndphu,项目名称:rss-management-suite,代码行数:27,代码来源:RSSForDOTA.cs

示例14: Convert

        /// <summary>
        ///     Converts entries in a XML document.
        /// </summary>
        /// <param name="entries">The entries.</param>
        /// <returns>The XML document that represents the entries.</returns>
        public string Convert(IEnumerable<string> entries)
        {
            var doc = new XmlDocument();
            var xmlDeclaration = doc.CreateXmlDeclaration("1.0", "utf-8", null);
            var root = doc.DocumentElement;
            doc.InsertBefore(xmlDeclaration, root);

            var rootElement = doc.CreateElement("directory");
            foreach (var entry in entries)
            {
                var element = doc.CreateElement("entry");
                var textNode = doc.CreateTextNode(entry);
                element.AppendChild(textNode);
                rootElement.AppendChild(element);
            }

            doc.AppendChild(rootElement);

            using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture))
            using (var xmlTextWriter = XmlWriter.Create(stringWriter))
            {
                doc.WriteTo(xmlTextWriter);
                xmlTextWriter.Flush();
                return stringWriter.GetStringBuilder().ToString();
            }
        }
开发者ID:digideskio,项目名称:AppDataRest,代码行数:31,代码来源:XmlDirectoryEntriesConverter.cs

示例15: Main

		public static int Main (string [] args)
		{
			if (args.Length == 0)
				return 1;

			AbiMode = false;

			AssemblyCollection acoll = new AssemblyCollection ();

			foreach (string arg in args) {
				if (arg == "--abi")
					AbiMode = true;
				else
					acoll.Add (arg);
			}

			XmlDocument doc = new XmlDocument ();
			acoll.Document = doc;
			acoll.DoOutput ();

			var writer = new WellFormedXmlWriter (new XmlTextWriter (Console.Out) { Formatting = Formatting.Indented });
			XmlNode decl = doc.CreateXmlDeclaration ("1.0", "utf-8", null);
			doc.InsertBefore (decl, doc.DocumentElement);
			doc.WriteTo (writer);
			return 0;
		}
开发者ID:stabbylambda,项目名称:mono,代码行数:26,代码来源:mono-api-info.cs


注:本文中的System.Xml.XmlDocument.CreateXmlDeclaration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。