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


C# XmlNode.AppendChild方法代码示例

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


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

示例1: XmlSecurityRatings

        public XmlSecurityRatings()
        {
            _document = new XmlDocument();

            /// _securityRatings = _document.CreateNode(XmlNodeType.Element, "SecurityRatings", XmlSecurityRatings._securityNs);
            _securityRatings = _document.CreateNode(XmlNodeType.Element, "SecurityRatings", null);
            _document.AppendChild(_securityRatings);

            _highSecurity = _document.CreateNode(XmlNodeType.Element, "High", null);
            _securityRatings.AppendChild(_highSecurity);
            appendAttribute(_highSecurity, @"title", @"HIGH RISK");
            appendAttribute(_highSecurity, @"comment", @"This document contains high risk elements");
            appendAttribute(_highSecurity, @"color", @"#B14343");
            appendAttribute(_highSecurity, @"include-in-summary", @"yes");
            appendAttribute(_highSecurity, @"hiddendata", @"This document contains high risk hidden data");
            appendAttribute(_highSecurity, @"contentpolicy", @"This document contains high risk content policy violations");

            _mediumSecurity = _document.CreateNode(XmlNodeType.Element, "Medium", null);
            _securityRatings.AppendChild(_mediumSecurity);
            appendAttribute(_mediumSecurity, @"title", @"MEDIUM RISK");
            appendAttribute(_mediumSecurity, @"comment", @"This document contains medium risk elements");
            appendAttribute(_mediumSecurity, @"color", @"#F0C060");
            appendAttribute(_mediumSecurity, @"include-in-summary", @"yes");
            appendAttribute(_mediumSecurity, @"hiddendata", @"This document contains medium risk hidden data");
            appendAttribute(_mediumSecurity, @"contentpolicy", @"This document contains medium risk content policy violations");

            _lowSecurity = _document.CreateNode(XmlNodeType.Element, "Low", null);
            _securityRatings.AppendChild(_lowSecurity);
            appendAttribute(_lowSecurity, @"title", @"LOW RISK");
            appendAttribute(_lowSecurity, @"comment", @"This document contains normal elements");
            appendAttribute(_lowSecurity, @"color", @"#4E7C49");
            appendAttribute(_lowSecurity, @"include-in-summary", @"no");
            appendAttribute(_lowSecurity, @"hiddendata", @"This document contains low risk hidden data");
            appendAttribute(_lowSecurity, @"contentpolicy", @"This document contains low risk content policy violations");
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:35,代码来源:XmlSecurityRatings.cs

示例2: genererXML

        /// <summary>
        /// Permet de générer la partie XML de Astronaute
        /// </summary>
        /// <param name="xmlDoc">XmlDocument global</param>
        /// <param name="xmlDocActs">XmlDocument pour les activités de base</param>
        /// <param name="astronaute">Le noeud de l'astronaute</param>
        /// <param name="acts">Le noeud de l'activité (base)</param>
        /// <param name="progression">L'interface de progression</param>
        public void genererXML(XmlDocument xmlDoc, XmlDocument xmlDocActs, XmlNode astronaute, XmlNode acts, Progression progression)
        {
            XmlNode nom = xmlDoc.CreateElement("Nom");
            nom.InnerText = this.nom;
            astronaute.AppendChild(nom);

            XmlNode prenom = xmlDoc.CreateElement("Prenom");
            prenom.InnerText = this.prenom;
            astronaute.AppendChild(prenom);

            XmlNode age = xmlDoc.CreateElement("Age");
            age.InnerText = this.age.ToString();
            astronaute.AppendChild(age);

            XmlNode journees = xmlDoc.CreateElement("JourneesMission");
            astronaute.AppendChild(journees);

            for (int i = 1; i <= journeesMission.Count; ++i)
            {
                XmlNode journee = xmlDoc.CreateElement("Journee");
                journees.AppendChild(journee);

                journeesMission[i].genererXML(xmlDoc, xmlDocActs, journee, acts, progression);
                progression.incrementer();
            }
        }
开发者ID:Nalhyyk,项目名称:MarsCalendar,代码行数:34,代码来源:Astronaute.cs

示例3: fAppendNode

 public void fAppendNode(ref XmlNode WhereToAppend, ref XmlNode WhatToAppend)
 {
     try
     {
         WhereToAppend.AppendChild(WhatToAppend);
     }
     catch (Exception ex)
     {
         if (ex.Message.ToUpper() == "THE NODE TO BE INSERTED IS FROM A DIFFERENT DOCUMENT CONTEXT.")
         {
             try
             {
                 WhereToAppend.AppendChild(WhereToAppend.OwnerDocument.ImportNode(WhatToAppend, true));
             }
             catch (Exception e)
             {
                 throw e;
             }
         }
         else
         {
             throw ex;
         }
     }
 }
开发者ID:stiqraschool,项目名称:eSchool,代码行数:25,代码来源:XMLLib.cs

示例4: AddOutputColumns

        public static void AddOutputColumns(XmlDocument doc, XmlNode outputNode, XmlNode resultRow)
        {
            foreach (XmlNode childNode in outputNode.ChildNodes)
            {
                XmlAttribute outStatusAttr = GetAttributeByName(childNode, "status");
                XmlAttribute outExpectedAttr = GetAttributeByName(childNode, "expected");
                XmlAttribute outActualAttr = GetAttributeByName(childNode, "actual");

                string outStatus = "outputvalue_" + outStatusAttr.Value;
                if (outStatusAttr.Value == ResultParser.ResultType.UNMATCH)
                {
                    XmlElement outputData = CreateDataElement(doc, outExpectedAttr.Value, outputExpectedColor, outStatus);
                    XmlElement resultData = CreateDataElement(doc, outActualAttr.Value, outputUnMatchColor, outStatus);
                    resultRow.AppendChild(outputData);
                    resultRow.AppendChild(resultData);
                    if (outActualAttr.Value == "")
                    {
                        resultData.SetAttribute("width", "3px");
                    }
                }
                else
                {
                    string outBgcolor = GetOutputColor(outStatusAttr.Value);
                    string outValue = outActualAttr.Value;
                    if (outExpectedAttr.Value != "")
                    {
                        outValue = outExpectedAttr.Value;
                    }
                    XmlElement outputData = CreateDataElement(doc, outValue, outBgcolor, outStatus);
                    outputData.SetAttribute("colspan", "2");
                    resultRow.AppendChild(outputData);
                }
            }
        }
开发者ID:MarMar,项目名称:SeeFlaw,代码行数:34,代码来源:HtmlTransformer.cs

示例5: AssociationNode

        public AssociationNode(WordDocument doc, string guid, string name, string endName, string endMP, string associationType, string connectionType)
        {
            IsRemained = true;
            AssociationGUID = guid;
            AssociationConnectionType = connectionType;
            _doc = doc;

            AssociationXmlNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ASSOC_SECTION, guid, connectionType);
            XmlNode assocNameNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ASSOC_NAME);
            if (associationType.Equals(Constants.Association))
                assocNameNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_ASSOC_NAME_PREFIX, name, Definitions.CLASS_ASSOC_NAME));
            else
                assocNameNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_COMPOSITION_NAME_PREFIX, name, Definitions.CLASS_ASSOC_NAME));
            AssociationXmlNode.AppendChild(assocNameNode);

            XmlNode assocDescrNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ASSOC_DESCR);
            assocDescrNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_ASSOC_DESCR_PREFIX, string.Empty, Definitions.CLASS_ASSOC_DESCR));
            AssociationXmlNode.AppendChild(assocDescrNode);

            XmlNode assocNameEndNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ASSOC_NAME_END);
            assocNameEndNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_ASSOC_NAME_END_PREFIX, endName, Definitions.CLASS_ASSOC_NAME_END));
            AssociationXmlNode.AppendChild(assocNameEndNode);

            XmlNode assocMultNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ASSOC_MULT);
            assocMultNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_ASSOC_MULT_PREFIX, endMP, Definitions.CLASS_ASSOC_MULT));
            AssociationXmlNode.AppendChild(assocMultNode);

            XmlNode assocTypeNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ASSOC_TYPE);
            assocTypeNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_ASSOC_TYPE_PREFIX, associationType, Definitions.CLASS_ASSOC_TYPE));
            AssociationXmlNode.AppendChild(assocTypeNode);
        }
开发者ID:Obles,项目名称:vwdaddin,代码行数:31,代码来源:AssociationNode.cs

示例6: SaveXml

        internal virtual void SaveXml(XmlNode xmlParent)
        {
            XmlAttribute xmlAttribute = null;
            XmlElement xmlElement = null;
		
		      
            if ( _id != 0 )
            {
                xmlAttribute = xmlParent.OwnerDocument.CreateAttribute("id");
                xmlAttribute.Value = _id.ToString();
                xmlParent.Attributes.Append(xmlAttribute);
            }
          
            if ( _timestamp != DateTime.MinValue )
            {
                xmlAttribute = xmlParent.OwnerDocument.CreateAttribute("timestamp");
                xmlAttribute.Value = _timestamp.ToString("yyyy/MM/dd HH:mm:ss");;
                xmlParent.Attributes.Append(xmlAttribute);
            }
          
            if ( _visible != "" )
            {
                xmlAttribute = xmlParent.OwnerDocument.CreateAttribute("visible");
                xmlAttribute.Value = _visible;
                xmlParent.Attributes.Append(xmlAttribute);
            }
          
            if ( _action != "" )
            {
                xmlAttribute = xmlParent.OwnerDocument.CreateAttribute("action");
                xmlAttribute.Value = _action;
                xmlParent.Attributes.Append(xmlAttribute);
            }
          
            foreach ( nd item in _ndCollection )
            {
                xmlElement = xmlParent.OwnerDocument.CreateElement("nd");
                item.SaveXml(xmlElement);
                // When nothing is on the xmlElement then don't add it				
                if ( xmlElement.ChildNodes.Count != 0 || xmlElement.Attributes.Count != 0 || xmlElement.InnerXml.Length != 0 )
                    xmlParent.AppendChild(xmlElement);
            }
          
            foreach ( tag item in _tagCollection )
            {
                xmlElement = xmlParent.OwnerDocument.CreateElement("tag");
                item.SaveXml(xmlElement);
                // When nothing is on the xmlElement then don't add it				
                if ( xmlElement.ChildNodes.Count != 0 || xmlElement.Attributes.Count != 0 || xmlElement.InnerXml.Length != 0 )
                    xmlParent.AppendChild(xmlElement);
            }
          
        }
开发者ID:zainGohar,项目名称:osm2shp,代码行数:53,代码来源:way.cs

示例7: AttributeNode

        public AttributeNode(WordDocument doc, string attribute)
        {
            AttrName = attribute;
            AttributeXMLNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ATTR_SECTION);
            XmlNode attrNameNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ATTR_NAME);
            attrNameNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_ATTR_NAME_PREFIX, attribute, Definitions.CLASS_ATTR_NAME));
            AttributeXMLNode.AppendChild(attrNameNode);

            XmlNode attrDescrNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ATTR_DESCR);
            attrDescrNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_ATTR_NAME_DESCR_PREFIX, string.Empty, Definitions.CLASS_ATTR_DESCR));
            AttributeXMLNode.AppendChild(attrDescrNode);
        }
开发者ID:Obles,项目名称:vwdaddin,代码行数:12,代码来源:AttributeNode.cs

示例8: AppendElement

        public static XmlNode AppendElement( XmlNode node, string newElementName, string innerValue )
        {
            XmlNode oNode ;

            if ( node is XmlDocument )
                oNode = node.AppendChild( ((XmlDocument)node).CreateElement( newElementName ) ) ;
            else
                oNode = node.AppendChild( node.OwnerDocument.CreateElement( newElementName ) ) ;

            if ( innerValue != null )
                oNode.AppendChild( node.OwnerDocument.CreateTextNode( innerValue ) ) ;

            return oNode ;
        }
开发者ID:ErekTan,项目名称:HLedo,代码行数:14,代码来源:XmlUtil.cs

示例9: AddChild

 public static XmlElement AddChild(XmlNode parent, string name)
 {
     XmlDocument document = (parent is XmlDocument) ? (XmlDocument) parent : parent.OwnerDocument;
     XmlElement node = document.CreateElement(name);
     parent.AppendChild(node);
     return node;
 }
开发者ID:vardars,项目名称:ci-factory,代码行数:7,代码来源:XmlUtil.cs

示例10: CreateRecord

        /// <summary>
        /// Creates the entity.
        /// </summary>
        /// <param name="objRequestInfo">The requestinfo object.</param>
        /// <param name="EntitiesElement">The entities element.</param>
        private void CreateRecord(Records records, XmlNode recordsNode)
        {
            XmlElement RecordElement;

            foreach (Record objRecord in records.Record)
            {
                RecordElement = objXmlDocument.CreateElement("record");
                recordsNode.AppendChild(RecordElement);
                if (objRecord.Order.Length > 0)
                {
                    XmlAttribute OrderAttribute = objXmlDocument.CreateAttribute("order");
                    RecordElement.Attributes.Append(OrderAttribute);
                    OrderAttribute.Value = objRecord.Order;
                }
                if (objRecord.RecordNumber.Length > 0)
                {
                    XmlAttribute RecordNumberAttribute = objXmlDocument.CreateAttribute("recordNumber");
                    RecordElement.Attributes.Append(RecordNumberAttribute);
                    RecordNumberAttribute.Value = objRecord.RecordNumber;
                }
                if (objRecord.RecordInfo != null)
                {
                    CreateRecordInfo(objRecord.RecordInfo, RecordElement);
                }
                //if (objRecord.RecordHistories != null)
                //{
                //    CreateRecordHistories(objRecord.RecordHistories, RecordElement);
                //}
            }
        }
开发者ID:vijaymca,项目名称:Dotnet,代码行数:35,代码来源:ListViewerXMLGeneratorBLL.cs

示例11: AddChild

 private void AddChild(String xml, XmlNode node)
 {
     XmlDocument temp = new XmlDocument();
     temp.LoadXml(xml);
     XmlNode child = node.OwnerDocument.ImportNode(temp.DocumentElement, true);
     node.AppendChild(child);
 }
开发者ID:ephemere,项目名称:Translator,代码行数:7,代码来源:MainForm.cs

示例12: AddPlayerValue

 private void AddPlayerValue(XmlDocument file, XmlNode node, string name, string value)
 {
     XmlElement element = file.CreateElement(name);
     XmlText text = file.CreateTextNode(value);
     element.AppendChild(text);
     node.AppendChild(element);
 }
开发者ID:draek,项目名称:circle-sharp,代码行数:7,代码来源:Players.cs

示例13: SetNewValue

 public static XmlNode SetNewValue(XmlNode contextNode, string nodeName, string nodeValue)
 {
     XmlNode node = (contextNode.OwnerDocument ?? ((XmlDocument) contextNode)).CreateElement(nodeName);
     contextNode.AppendChild(node);
     node.InnerText = nodeValue;
     return node;
 }
开发者ID:jmcadams,项目名称:vplus,代码行数:7,代码来源:Xml.cs

示例14: SetValue

        public bool SetValue(string key, string value)
        {
            //增加 

            // retrieve the appSettings node    
            node = cfgDoc.SelectSingleNode("//appSettings");
            if (node == null)
            {
                throw new InvalidOperationException("appSettings section not found");
            }

            // XPath select setting "add" element that contains this key        
            var addElem = (XmlElement) node.SelectSingleNode("//add[@key='" + key + "']");
            if (addElem != null)
            {
                message = "此key已经存在!";
                return false;
            }
                // not found, so we need to add the element, key and value    
            else
            {
                XmlElement entry = cfgDoc.CreateElement("add");
                entry.SetAttribute("key", key);
                entry.SetAttribute("value", value);
                node.AppendChild(entry);
            }
            //save it    
            saveConfigDoc(cfgDoc, docName);
            message = "添加成功!";
            return true;
        }
开发者ID:reckcn,项目名称:DevLib.Comm,代码行数:31,代码来源:ReadWriteAppSettings.cs

示例15: LoadData

        public void LoadData()
        {
            lock (this)
            {
                doc = new XmlDocument();
                if (File.Exists(fileName))
                {
                    XmlTextReader reader = new XmlTextReader(fileName);
                    reader.WhitespaceHandling = WhitespaceHandling.None;
                    doc.Load(reader);
                    reader.Close();
                }
                else
                {
                    createdFile = true;
                    rootNode = doc.CreateNode(XmlNodeType.Element, "Root", String.Empty);
                    doc.AppendChild(rootNode);
                    configNode = doc.CreateNode(XmlNodeType.Element, "Config", String.Empty);
                    rootNode.AppendChild(configNode);
                }

                LoadDataToClass();

                if (createdFile)
                {
                    Commit();
                }
            }
        }
开发者ID:Michelle-Argus,项目名称:opensim,代码行数:29,代码来源:XmlConfiguration.cs


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