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


C# XmlDocument.CreateElement方法代码示例

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


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

示例1: SaveNode

        protected override void SaveNode(XmlDocument xmlDoc, XmlElement nodeElement, SaveContext context)
        {
            Controller.SaveNode(xmlDoc, nodeElement, context);
            
            var outEl = xmlDoc.CreateElement("Name");
            outEl.SetAttribute("value", NickName);
            nodeElement.AppendChild(outEl);

            outEl = xmlDoc.CreateElement("Description");
            outEl.SetAttribute("value", Description);
            nodeElement.AppendChild(outEl);

            outEl = xmlDoc.CreateElement("Inputs");
            foreach (string input in InPortData.Select(x => x.NickName))
            {
                XmlElement inputEl = xmlDoc.CreateElement("Input");
                inputEl.SetAttribute("value", input);
                outEl.AppendChild(inputEl);
            }
            nodeElement.AppendChild(outEl);

            outEl = xmlDoc.CreateElement("Outputs");
            foreach (string output in OutPortData.Select(x => x.NickName))
            {
                XmlElement outputEl = xmlDoc.CreateElement("Output");
                outputEl.SetAttribute("value", output);
                outEl.AppendChild(outputEl);
            }
            nodeElement.AppendChild(outEl);
        }
开发者ID:khoaho,项目名称:Dynamo,代码行数:30,代码来源:Function.cs

示例2: OverWriting

        private bool OverWriting() {
        //private async Task<bool> OverWriting() {
            if (ListingQueue.Any()) {
                XmlDocument xmlDoc;
                XmlElement xmlEle;
                XmlNode newNode;

                xmlDoc = new XmlDocument();
                xmlDoc.Load("ImageData.xml"); // XML문서 로딩

                newNode = xmlDoc.SelectSingleNode("Images"); // 추가할 부모 Node 찾기
                xmlEle = xmlDoc.CreateElement("Image");
                newNode.AppendChild(xmlEle);
                newNode = newNode.LastChild;
                xmlEle = xmlDoc.CreateElement("ImagePath"); // 추가할 Node 생성
                xmlEle.InnerText = ListingQueue.Peek();
                ListingQueue.Dequeue();
                newNode.AppendChild(xmlEle); // 위에서 찾은 부모 Node에 자식 노드로 추가..

                xmlDoc.Save("ImageData.xml"); // XML문서 저장..
                xmlDoc = null;

                return true;
            }
            return false;
        }
开发者ID:InhoChoi,项目名称:KICOM,代码行数:26,代码来源:WriteImageList.cs

示例3: GetXML

        private string GetXML()
        {
            XmlDocument document = new XmlDocument();

            XmlElement RazaoNode = document.CreateElement("Razao");
            RazaoNode.InnerText = Razao;

            XmlElement ValoresNode = document.CreateElement("Valores");
            XmlElement ValorNode = document.CreateElement("Valor");

            XmlAttribute moeda = document.CreateAttribute("moeda");
            moeda.Value = "BRL";

            ValorNode.Attributes.Append(moeda);
            ValorNode.InnerText = String.Format("{0:0.00}", Valor).Replace(',','.');

            ValoresNode.AppendChild(ValorNode);

            XmlNode EnviarInstrucao = document.CreateElement("EnviarInstrucao");
            XmlNode InstrucaoUnica = EnviarInstrucao.AppendChild(document.CreateNode(XmlNodeType.Element, "InstrucaoUnica", ""));

            InstrucaoUnica.AppendChild(RazaoNode);
            InstrucaoUnica.AppendChild(ValoresNode);

            return EnviarInstrucao.OuterXml;
        }
开发者ID:moiplabs,项目名称:MoIP.NET,代码行数:26,代码来源:MoIP.cs

示例4: GetHttpRuntime

        public static XmlElement GetHttpRuntime(XmlDocument configuration, bool createIfMissing = false)
        {
            var systemWeb = configuration.SelectSingleElement("/configuration/system.web");
              if (systemWeb == null)
              {
            if (!createIfMissing)
            {
              return null;
            }

            systemWeb = configuration.CreateElement("system.web");
            configuration.DocumentElement.AppendChild(systemWeb);
              }

              var httpRuntime = systemWeb.SelectSingleElement("httpRuntime");
              if (httpRuntime != null)
              {
            return httpRuntime;
              }

              if (!createIfMissing)
              {
            return null;
              }

              httpRuntime = configuration.CreateElement("httpRuntime");
              systemWeb.AppendChild(httpRuntime);

              return httpRuntime;
        }
开发者ID:Sitecore,项目名称:Sitecore-Instance-Manager,代码行数:30,代码来源:UpdateWebConfigHelper.cs

示例5: Save

 public void Save(string path)
 {
     this.time = DateTime.Now;
     if (!File.Exists(path))
     {
         XmlWriter writer = XmlWriter.Create(path);
         writer.WriteStartElement("head");
         writer.WriteFullEndElement();
         writer.Close();
     }
     XmlDocument doc = new XmlDocument();
     doc.Load(path);
     XmlNode root = doc.DocumentElement;
     XmlElement newOrder = doc.CreateElement("OrderId");
     XmlElement newUser = doc.CreateElement("UserId");
     XmlElement newTime = doc.CreateElement("Time");
     XmlText orderId = doc.CreateTextNode(this.IdOrder.ToString());
     XmlText userId = doc.CreateTextNode(this.IdUser.ToString());
     XmlText checkTime = doc.CreateTextNode(this.time.ToString("o"));
     newOrder.AppendChild(orderId);
     newUser.AppendChild(userId);
     newTime.AppendChild(checkTime);
     root.InsertAfter(newOrder, root.LastChild);
     root.InsertAfter(newUser, root.LastChild);
     root.InsertAfter(newTime, root.LastChild);
     doc.Save(path);
 }
开发者ID:NoProgramist,项目名称:PMI21_TeachingPractice,代码行数:27,代码来源:Check.cs

示例6: 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

示例7: ToText

        public override string ToText(Subtitle subtitle, string title)
        {
            string xmlStructure = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + Environment.NewLine + "<Subtitle/>";

            XmlDocument xml = new XmlDocument();
            xml.LoadXml(xmlStructure);

            foreach (Paragraph p in subtitle.Paragraphs)
            {
                XmlNode paragraph = xml.CreateElement("Paragraph");

                XmlNode number = xml.CreateElement("Number");
                number.InnerText = p.Number.ToString();
                paragraph.AppendChild(number);

                XmlNode start = xml.CreateElement("StartMilliseconds");
                start.InnerText = p.StartTime.TotalMilliseconds.ToString(CultureInfo.InvariantCulture);
                paragraph.AppendChild(start);

                XmlNode end = xml.CreateElement("EndMilliseconds");
                end.InnerText = p.EndTime.TotalMilliseconds.ToString(CultureInfo.InvariantCulture);
                paragraph.AppendChild(end);

                XmlNode text = xml.CreateElement("Text");
                text.InnerText = HtmlUtil.RemoveHtmlTags(p.Text);
                paragraph.AppendChild(text);

                xml.DocumentElement.AppendChild(paragraph);
            }

            return ToUtf8XmlString(xml);
        }
开发者ID:KatyaMarincheva,项目名称:SubtitleEditOriginal,代码行数:32,代码来源:TimeXml.cs

示例8: tokenize

		/// <summary>
		/// Implements the following function 
		///		node-set tokenize(string, string)
		/// </summary>
		/// <param name="str"></param>
		/// <param name="delimiters"></param>				
		/// <returns>This function breaks the input string into a sequence of strings, 
		/// treating any character in the list of delimiters as a separator. 
		/// The separators themselves are not returned. 
		/// The tokens are returned as a set of 'token' elements.</returns>
		public XPathNodeIterator tokenize(string str, string delimiters)
		{

			XmlDocument doc = new XmlDocument();
			doc.LoadXml("<tokens/>");

			if (delimiters == String.Empty)
			{
				foreach (char c in str)
				{
					XmlElement elem = doc.CreateElement("token");
					elem.InnerText = c.ToString();
					doc.DocumentElement.AppendChild(elem);
				}
			}
			else
			{
				foreach (string token in str.Split(delimiters.ToCharArray()))
				{

					XmlElement elem = doc.CreateElement("token");
					elem.InnerText = token;
					doc.DocumentElement.AppendChild(elem);
				}
			}

			return doc.CreateNavigator().Select("//token");
		}
开发者ID:zanyants,项目名称:mvp.xml,代码行数:38,代码来源:ExsltStrings.cs

示例9: Save

        /// <summary>
        /// Saves the contents of this instance to the defined config file.
        /// </summary>
        /// <param name="force">If false, will only save if the flag indicates that changes have been made. If true, always saves.</param>
        public void Save( bool force = false ) {
            if( force || outOfDate ) {
                Type t = this.GetType();

                PropertyInfo[] properties = t.GetProperties();
                XmlDocument doc = new XmlDocument();
                XmlElement config = doc.CreateElement( "config" );
                lock( threadLock ) {
                    foreach( PropertyInfo pi in properties ) {
                        object val = pi.GetValue( this, null );
                        if( val != null ) {
                            XmlElement element = doc.CreateElement( pi.Name );
                            element.InnerText = val.ToString();
                            config.AppendChild( element );
                        }
                    }
                }
                doc.AppendChild( config );
                try {
                    doc.Save( FilePath );
                } catch( IOException ) {
                }
                outOfDate = false;
            }
        }
开发者ID:EnemyWithin,项目名称:depressurizer,代码行数:29,代码来源:AppSettings.cs

示例10: addData

        public void addData(string XmlFilePath,StringBuilder str)
        {
            XmlDocument document = new XmlDocument();

                document.Load(XmlFilePath);
                XmlNode element = document.CreateElement("info");
                document.DocumentElement.AppendChild(element);

                XmlNode title = document.CreateElement("title");
                title.InnerText = XmlFilePath;
                element.AppendChild(title);

                XmlNode chapter = document.CreateElement("chapter");
                document.DocumentElement.AppendChild(chapter); // указываем родителя

                XmlNode para = document.CreateElement("para");
                para.InnerText = str.ToString();
                chapter.AppendChild(para);

                document.Save(XmlFilePath);

               // Console.WriteLine("Data have been added to xml!");

               // Console.ReadKey();
               // Console.WriteLine(XmlToJSON(document));
        }
开发者ID:KateSenko,项目名称:DocmToDocbook,代码行数:26,代码来源:DocBook.cs

示例11: Subscribe

        public string Subscribe(string deliveryUrl, string eventType)
        {
            string subscriptionId = Guid.NewGuid().ToString();

            XmlDocument subscriptionStore = new XmlDocument();
            subscriptionStore.Load(subscriptionStorePath);

            // Add a new subscription
            XmlNode newSubNode = subscriptionStore.CreateElement("Subscription");

            XmlNode subscriptionIdStart = subscriptionStore.CreateElement("SubscriptionID");
            subscriptionIdStart.InnerText = subscriptionId;
            newSubNode.AppendChild(subscriptionIdStart);

            XmlNode deliveryAddressStart = subscriptionStore.CreateElement("DeliveryAddress");
            deliveryAddressStart.InnerText = deliveryUrl;
            newSubNode.AppendChild(deliveryAddressStart);

            XmlNode eventTypeStart = subscriptionStore.CreateElement("EventType");
            eventTypeStart.InnerText = eventType;
            newSubNode.AppendChild(eventTypeStart);

            subscriptionStore.DocumentElement.AppendChild(newSubNode);

            subscriptionStore.Save(subscriptionStorePath);

            return subscriptionId;
        }
开发者ID:zohaib01khan,项目名称:Sharepoint-training-for-Learning,代码行数:28,代码来源:Default.aspx.cs

示例12: saveGesture

        //Saves given Unistroke to file as a new gesture with name specified
        public static void saveGesture(ref SignalProcessing.Unistroke<double> u, string name)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load("gestures.xml");
            XmlNodeList nl = doc.GetElementsByTagName("gesture_set");
            XmlElement gesture_elem= doc.CreateElement("gesture");
            XmlAttribute ident = doc.CreateAttribute("name");
            ident.InnerText = name;
            gesture_elem.Attributes.Append(ident);

            for(int i = 0; i < u.trace.Count; i++){
                XmlElement n = doc.CreateElement("point");
                XmlAttribute x = doc.CreateAttribute("x");
                XmlAttribute y = doc.CreateAttribute("y");
                XmlAttribute z = doc.CreateAttribute("z");
                x.InnerText = u[i].x.ToString();
                y.InnerText = u[i].y.ToString();
                z.InnerText = u[i].z.ToString();
                n.Attributes.Append(x);
                n.Attributes.Append(y);
                n.Attributes.Append(z);
                gesture_elem.AppendChild(n);
            }

            nl[0].AppendChild(gesture_elem);
            doc.Save("gestures.xml");
        }
开发者ID:mmuzny,项目名称:ActivityRecognition,代码行数:29,代码来源:PreProcessing.cs

示例13: GenerateStrings

        private void GenerateStrings(string inputPath, string outputFile)
        {
            XElement rootElement = XElement.Load(inputPath);
            IEnumerable<Tuple<string, string>> items = from dataElement in rootElement.Descendants("data")
                                                       let key = dataElement.Attribute("name").Value
                                                       let valueElement = dataElement.Element("value")
                                                       where valueElement != null
                                                       let value = valueElement.Value
                                                       select new Tuple<string, string>(key, value);
            XmlDocument document = new XmlDocument();
            document.AppendChild(document.CreateXmlDeclaration("1.0", "utf-8", null));
            XmlNode rootNode = document.CreateElement("resources");
            document.AppendChild(rootNode);

            foreach (var pair in items)
            {
                XmlNode elementNode = document.CreateElement("string");
                elementNode.InnerText = processValue(pair.Item2);
                XmlAttribute attributeName = document.CreateAttribute("name");
                attributeName.Value = processKey(pair.Item1);
                // ReSharper disable once PossibleNullReferenceException
                elementNode.Attributes.Append(attributeName);

                rootNode.AppendChild(elementNode);
            }

            document.Save(outputFile);
        }
开发者ID:snipervld,项目名称:StormXamarin,代码行数:28,代码来源:ReswToStrings.cs

示例14: GetMacro

		public XmlNode GetMacro(int Id, string Login, string Password)
		{
		    if (ValidateCredentials(Login, Password)
                && UserHasAppAccess(DefaultApps.developer.ToString(), Login)) 
			{
				var xmlDoc = new XmlDocument();
				var macro = xmlDoc.CreateElement("macro");
				var m = new cms.businesslogic.macro.Macro(Id);
                macro.Attributes.Append(XmlHelper.AddAttribute(xmlDoc, "id", m.Id.ToString()));
                macro.Attributes.Append(XmlHelper.AddAttribute(xmlDoc, "refreshRate", m.RefreshRate.ToString()));
                macro.Attributes.Append(XmlHelper.AddAttribute(xmlDoc, "useInEditor", m.UseInEditor.ToString()));
                macro.Attributes.Append(XmlHelper.AddAttribute(xmlDoc, "alias", m.Alias));
                macro.Attributes.Append(XmlHelper.AddAttribute(xmlDoc, "name", m.Name));
                macro.Attributes.Append(XmlHelper.AddAttribute(xmlDoc, "assembly", m.Assembly));
                macro.Attributes.Append(XmlHelper.AddAttribute(xmlDoc, "type", m.Type));
                macro.Attributes.Append(XmlHelper.AddAttribute(xmlDoc, "xslt", m.Xslt));
				var properties = xmlDoc.CreateElement("properties");
				foreach (var mp in m.Properties) 
				{
					var pXml = xmlDoc.CreateElement("property");
                    pXml.Attributes.Append(XmlHelper.AddAttribute(xmlDoc, "alias", mp.Alias));
                    pXml.Attributes.Append(XmlHelper.AddAttribute(xmlDoc, "name", mp.Name));
                    pXml.Attributes.Append(XmlHelper.AddAttribute(xmlDoc, "public", mp.Public.ToString()));
					properties.AppendChild(pXml);
				}
				macro.AppendChild(properties);
				return macro;
			}
		    return null;
		}
开发者ID:ChrisNikkel,项目名称:Umbraco-CMS,代码行数:30,代码来源:Developer.asmx.cs

示例15: Serialize

        /// <summary>
        /// Serializes the specified play list items.
        /// </summary>
        /// <param name="items">The play list.</param>
        /// <returns>The serielized play list as xml document.</returns>
        public XmlDocument Serialize(IEnumerable<ListViewItem> items)
        {
            var doc = new XmlDocument();

            XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "utf-8", "yes");
            doc.AppendChild(declaration);

            XmlElement root = doc.CreateElement("items");
            doc.AppendChild(root);

            foreach (ListViewItem item in items)
            {
                XmlElement element = doc.CreateElement("item");
                element.InnerText = item.Text;

                XmlAttribute startTime = doc.CreateAttribute("start");
                startTime.InnerText = item.SubItems[1].Text;
                element.Attributes.Append(startTime);

                XmlAttribute endTime = doc.CreateAttribute("end");
                endTime.InnerText = item.SubItems[2].Text;
                element.Attributes.Append(endTime);

                XmlAttribute duration = doc.CreateAttribute("duration");
                duration.InnerText = item.SubItems[3].Text;
                element.Attributes.Append(duration);

                root.AppendChild(element);
            }

            return doc;
        }
开发者ID:feg-giessen,项目名称:videocommander,代码行数:37,代码来源:PlaylistSerializer.cs


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