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


C# XmlNode.ReplaceChild方法代码示例

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


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

示例1: ReplaceDefs

        private static void ReplaceDefs(XmlNode xmlNode)
        {
            for (var i = 0; i < xmlNode.ChildNodes.Count; i++)
            {
                var childNode = xmlNode.ChildNodes[i];
                ReplaceDefs(childNode);
                if (childNode.Name != "defs")
                {
                    continue;
                }

                var gNode = childNode.OwnerDocument.CreateElement("g", childNode.NamespaceURI);
                foreach (XmlAttribute attribute in childNode.Attributes)
                {
                    gNode.SetAttributeNode((XmlAttribute)attribute.Clone());
                }
                gNode.SetAttribute("display", "none");
                while (childNode.HasChildNodes)
                {
                    gNode.AppendChild(childNode.FirstChild);
                }

                xmlNode.ReplaceChild(gNode, childNode);
            }
        }
开发者ID:rflechner,项目名称:SvgToVectorDrawableConverter,代码行数:25,代码来源:SvgPreprocessor.cs

示例2: Run

        private static XmlNode Run(XmlMerger merger, XmlNode ours, XmlNode theirs, XmlNode ancestor)
        {
            if (ours == null && theirs == null && ancestor == null)
                return null;

            if (ancestor == null)
            {
                return HandleCaseOfNoAncestor(merger, ours, theirs);
            }
            // ancestor is not null at this point.
            var mergeSituation = merger.MergeSituation;
            var pathToFileInRepository = mergeSituation.PathToFileInRepository;
            if (ours == null && theirs == null)
            {
                // We both deleted main node.
            // Route tested, but the MergeChildrenMethod adds the change report for us.
                merger.EventListener.ChangeOccurred(new XmlBothDeletionChangeReport(pathToFileInRepository, ancestor));
                return null;
            }
            if (ours == null)
            {
                return HandleOursNotPresent(merger, ancestor, theirs);
            }
            if (theirs == null)
            {
                return HandleTheirsNotPresent(merger, ancestor, ours);
            }
            // End of checking main parent node.

            // ancestor, ours, and theirs all exist here.
            var ourChild = GetElementChildren(ours).FirstOrDefault();
            var theirChild = GetElementChildren(theirs).FirstOrDefault();
            var ancestorChild = GetElementChildren(ancestor).FirstOrDefault();
            if (ourChild == null && theirChild == null && ancestorChild == null)
            {
                return ours; // All three are childless.
            }

            if (ancestorChild == null)
            {
                return HandleCaseOfNoAncestorChild(merger, ours, ourChild, theirChild);
            }
            var mergeStrategyForChild = merger.MergeStrategies.GetElementStrategy(ancestorChild);
            if (ourChild == null)
            {
                return HandleOurChildNotPresent(merger, ours, ancestor, theirChild, pathToFileInRepository, ancestorChild, mergeSituation, mergeStrategyForChild);
            }
            if (theirChild == null)
            {
                return HandleTheirChildNotPresent(merger, ours, ancestor, ancestorChild, ourChild, mergeSituation, mergeStrategyForChild, pathToFileInRepository);
            }

            // ancestorChild, ourChild, and theirChild all exist.
            // But, it could be that we or they deleted and added something.
            // Check for edit vs delete+add, or there can be two items in ours, which is not legal.
            var match = mergeStrategyForChild.MergePartnerFinder.GetNodeToMerge(ourChild, ancestor, SetFromChildren.Get(ancestor));
            if (match == null)
            {
                // we deleted it and added a new one.
                if (XmlUtilities.AreXmlElementsEqual(theirChild, ancestorChild))
                {
                    // Our delete+add wins, since they did nothing.
                    merger.EventListener.ChangeOccurred(new XmlDeletionChangeReport(pathToFileInRepository, ancestor, ancestorChild));
                    merger.EventListener.ChangeOccurred(new XmlAdditionChangeReport(pathToFileInRepository, ourChild));
                    return ours;
                }

                // They edited old one, so they win over our delete+add.
                merger.ConflictOccurred(new RemovedVsEditedElementConflict(theirChild.Name, theirChild, null, ancestorChild,
                                                                           mergeSituation, mergeStrategyForChild,
                                                                           mergeSituation.BetaUserId));
                ours.ReplaceChild(ours.OwnerDocument.ImportNode(theirChild, true), ourChild);
                return ours;
            }
            match = mergeStrategyForChild.MergePartnerFinder.GetNodeToMerge(theirChild, ancestor, SetFromChildren.Get(ancestor));
            if (match == null)
            {
                // they deleted it and added a new one.
                if (XmlUtilities.AreXmlElementsEqual(ourChild, ancestorChild))
                {
                    // Their delete+add wins, since we did nothing.
                    merger.EventListener.ChangeOccurred(new XmlDeletionChangeReport(pathToFileInRepository, ancestor, ancestorChild));
                    merger.EventListener.ChangeOccurred(new XmlAdditionChangeReport(pathToFileInRepository, theirChild));
                    ours.ReplaceChild(ours.OwnerDocument.ImportNode(theirChild, true), ourChild);
                    return ours;
                }

                // We edited old one, so we win over their delete+add.
                merger.ConflictOccurred(new RemovedVsEditedElementConflict(ourChild.Name, ourChild, null, ancestorChild,
                                                                           mergeSituation, mergeStrategyForChild,
                                                                           mergeSituation.AlphaUserId));
                return ours;
            }

            merger.MergeInner(ref ourChild, theirChild, ancestorChild);

            // Route tested. (UsingWith_NumberOfChildrenAllowed_ZeroOrOne_DoesNotThrowWhenParentHasOneChildNode)
            return ours;
        }
开发者ID:JessieGriffin,项目名称:chorus,代码行数:99,代码来源:MergeLimitedChildrenService.cs

示例3: walkBodyNodes

        private void walkBodyNodes(XmlNode node, HTMLParserContext parseContext)
        {
            XmlNodeList list = node.ChildNodes;
            for (int index = 0; index < list.Count; ++index )
            {
                XmlNode newNode = parseContext.replaceNode(list[index]);

                if (node.HasChildNodes && node != parseContext.IntermediateRootElement)
                {
                    //if (newNode.HasChildNodes)
                    //{
                    //    walkBodyNodes(newNode, parseContext); //Context of the original attributes is gone here so this should be moved to replaceNode
                    //}
                    node.ReplaceChild(newNode, list[index]);
                }
                else
                {
                    node.AppendChild(newNode);
                }

            }
        }
开发者ID:NightCreature,项目名称:HTMLUICompiler,代码行数:22,代码来源:HTMLParser.cs

示例4: ReplaceNode

		protected void ReplaceNode(XmlNode element, XmlNode newNode, XmlNode oldNode)
		{
			if (newNode == oldNode)
			{
				return;
			}

			var importedNode = ImportNode(element, newNode);

			element.ReplaceChild(importedNode, oldNode);
		}
开发者ID:janv8000,项目名称:Windsor,代码行数:11,代码来源:AbstractXmlNodeProcessor.cs

示例5: ProcessSageLinkElement

        internal static XmlNode ProcessSageLinkElement(SageContext context, XmlNode node)
        {
            Contract.Requires<ArgumentNullException>(node != null);
            if (node.SelectSingleElement("ancestor::sage:literal", XmlNamespaces.Manager) != null)
                return node;

            XmlElement linkElem = (XmlElement) node;
            string linkName = context.ProcessText(linkElem.GetAttribute("ref"));
            bool rawString = linkElem.GetAttribute("raw").EqualsAnyOf("1", "yes", "true");

            if (!string.IsNullOrEmpty(linkName) && rawString)
            {
                if (context.Url.Links.ContainsKey(linkName))
                {
                    linkElem.InnerText = context.Url.Links[linkName].Value;
                }

                return linkElem;
            }

            string linkHref = context.Url.GetUrl(linkElem);
            if (!string.IsNullOrEmpty(linkHref))
            {
                linkElem.SetAttribute("href", linkHref);
            }

            foreach (XmlNode child in node.ChildNodes)
            {
                XmlNode processed = NodeEvaluator.GetNodeHandler(child)(context, child);
                if (processed != null)
                    node.ReplaceChild(processed, child);
                else
                    node.RemoveChild(child);
            }

            return linkElem;
        }
开发者ID:igorfrance,项目名称:sage,代码行数:37,代码来源:UrlGenerator.cs

示例6: HandleNode

        private static string HandleNode(XmlNode node)
        {
            var cNodes = node.SelectNodes("c");
            var codeNodes = node.SelectNodes("code");
            var list = cNodes.Cast<XmlNode>().Concat<XmlNode>(codeNodes.Cast<XmlNode>());

            foreach (XmlNode cNode in list)
            {
                XmlElement pre = node.OwnerDocument.CreateElement("pre");
                XmlElement code = node.OwnerDocument.CreateElement("code");
                code.InnerXml = HandleNode(cNode);
                pre.AppendChild(code);
                node.ReplaceChild(pre, cNode);
            }

            cNodes = node.SelectNodes("para");
            foreach (XmlNode cNode in cNodes)
            {
                XmlElement p = node.OwnerDocument.CreateElement("p");
                p.InnerXml = HandleNode(cNode);
                node.ReplaceChild(p, cNode);
            }

            list = node.SelectNodes("paramref").Cast<XmlNode>().Concat<XmlNode>(node.SelectNodes("typeparamref").Cast<XmlNode>());
            foreach (XmlNode cNode in list)
            {
                XmlElement p = node.OwnerDocument.CreateElement("b");
                var attr = node.Attributes["name"];
                p.InnerXml = attr != null ? attr.InnerText : "";
                node.ReplaceChild(p, cNode);
            }

            cNodes = node.SelectNodes("see");
            foreach (XmlNode cNode in cNodes)
            {
                var attr = node.Attributes["cref"];
                XmlText p = node.OwnerDocument.CreateTextNode(string.Format("{{@link {0}}}", attr != null ? attr.InnerText : ""));
                node.ReplaceChild(p, cNode);
            }

            RemoveNodes(node, "include");
            RemoveNodes(node, "list");
            RemoveNodes(node, "permission");

            return node.InnerXml.Trim();
        }
开发者ID:TinkerWorX,项目名称:Bridge,代码行数:46,代码来源:XmlToJsDoc.cs

示例7: AddBondAttributes

        private static void AddBondAttributes(XmlDocument xdocNewInvestmentData, XmlNode xnodeInvestment, string name, ref string desc, ref string exchCode, string country, string coupon, string maturity, string accrualDaysPerMonth, string accrualDaysPerYear)
        {
            desc = String.Format("{0} {1} {2}", name, coupon.Trim().TrimEnd('0'), maturity);
            exchCode = country;

            XmlNode accrualDaysPerMonthNode = xdocNewInvestmentData.CreateNode(XmlNodeType.Element, "AccrualDaysPerMonth", "");
            accrualDaysPerMonthNode.InnerText = accrualDaysPerMonth.Replace("ACT", "Actual");
            xnodeInvestment.AppendChild(accrualDaysPerMonthNode);

            XmlNode accrualDaysPerYearNode = xdocNewInvestmentData.CreateNode(XmlNodeType.Element, "AccrualDaysPerYear", "");
            accrualDaysPerYearNode.InnerText = accrualDaysPerYear.Replace("ACT", "Actual"); ;
            xnodeInvestment.AppendChild(accrualDaysPerYearNode);

            XmlNode longDecriptionNode = xdocNewInvestmentData.CreateNode(XmlNodeType.Element, "LongDescription", "");
            longDecriptionNode.InnerText = desc;
            xnodeInvestment.AppendChild(longDecriptionNode);

            XmlNode exchNode = xnodeInvestment.SelectSingleNode("EXCH_CODE");
            exchNode.InnerText = country;
            xnodeInvestment.ReplaceChild(exchNode, xnodeInvestment.SelectSingleNode("EXCH_CODE"));
        }
开发者ID:BrianGoff,项目名称:BITS,代码行数:21,代码来源:SimpleGetDataRequest.cs

示例8: replaceCodeBase

 private void replaceCodeBase(XmlNode node, string path)
 {
     XmlNode identity = node.FirstChild;
        XmlNode codebase = identity.NextSibling;
        Uri fileURI = new Uri(Path.Combine(path, Path.Combine(@"web\bin", ((XmlElement)identity).GetAttribute("name") + ".dll")));
        string ns = codebase.GetNamespaceOfPrefix(String.Empty);
        XmlElement element = configDoc.CreateElement(String.Empty, "codeBase", ns);
        element.SetAttribute("href", fileURI.AbsoluteUri);
        node.ReplaceChild(element, codebase);
 }
开发者ID:RoDaniel,项目名称:featurehouse,代码行数:10,代码来源:iFolderAppInstallerClass.cs

示例9: ConvertRoutingTableRoutingItemChildNode

        private void ConvertRoutingTableRoutingItemChildNode(XmlNode routingTable, bool isInternalExternal, string oldChildNodeName, string newChildNodeName)
        {
            if ((null == routingTable) || (string.IsNullOrEmpty(oldChildNodeName)) || (string.IsNullOrEmpty(newChildNodeName)))
                return;

            XmlNode oldNode = routingTable.SelectSingleNode(oldChildNodeName);
            if (null == oldNode)
                return;

            XmlNode newNode = routingTable.OwnerDocument.CreateElement(newChildNodeName);
            XmlAttribute channelTypeAttribute = routingTable.Attributes["type"];
            Workshare.Policy.ChannelType channelType = Workshare.Policy.TypeConverters.GetChannelType(channelTypeAttribute.Value);
           
            foreach (XmlNode addressCollectionNode in oldNode.ChildNodes)
            {
                XmlNode routingItemCollectionNode = routingTable.OwnerDocument.CreateElement("RoutingItemCollection");
                CopyAttributes(addressCollectionNode, routingItemCollectionNode);
                newNode.AppendChild(routingItemCollectionNode);

                if (Workshare.Policy.ChannelType.SMTP == channelType)
                {
                    InsertSmtpRoutingAssemblyInformation(routingItemCollectionNode, isInternalExternal);
                }
            }

            routingTable.ReplaceChild(newNode, oldNode);
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:27,代码来源:PolicySetVersionConverter_1_2.cs

示例10: AddTypes

        private static void AddTypes(XmlDocument swaggerDocument, XmlNode node, string ns, string element, string typeName)
        {
            if (ns == null && element == null)
            {
                return;
            }

            var type = node.SelectSingleNode("type");

            XmlElement xmltype = swaggerDocument.CreateElement(type.Name);
            xmltype.SetAttribute("namespace", ns);
            xmltype.SetAttribute("element", element);
            xmltype.InnerXml = typeName;

            node.ReplaceChild(xmltype, type);
        }
开发者ID:sudarsanan-krishnan,项目名称:DynamicsCRMConnector,代码行数:16,代码来源:XmlSwaggerGenerator.cs

示例11: _replaceNode

 private void _replaceNode(XmlNode vPrent, XmlNode vDest, XmlNode vSrc){
   if(vPrent != null){
     XmlNode newNode = this._cloneNode(vPrent.OwnerDocument, vSrc);
     vPrent.ReplaceChild(newNode, vDest);
   }
 }
开发者ID:tormoz70,项目名称:Bio.Framework.8,代码行数:6,代码来源:dom4cs.cs

示例12: AnalyzeChildSqlNode

 /// <summary>
 /// 解析sqlNode
 /// </summary>
 /// <param name="sqlNode">sql节点</param>
 /// <returns>解析后的sql</returns>
 public static XmlNode AnalyzeChildSqlNode(XmlNode sqlNode, List<IDbDataParameter> parmeters)
 {
     /*
      * <isEmpty property="ZTECntNo">d.zte_cnt_no like #ZTECntNo#</isNotEmpty>
      * <isNotEmpty property="ZTECntNo">d.zte_cnt_no like #ZTECntNo#</isNotEmpty>
      * <isEqual  property="IsShowSended" compareValue="0"></isEqual>
      * <isNotEqual property="IsShowSended" compareValue="0"></isNotEqual>
      */
     sqlNode = sqlNode.Clone();
     if (parmeters != null && parmeters.Count > 0)
     {
         //去除isEmpty
         var isEmptyList = sqlNode.SelectNodes("isEmpty");
         foreach (XmlNode node in isEmptyList)
         {
             string nodeproperty = node.Attributes["property"].Value;
             var p = (from o in parmeters
                      where o.ParameterName.ToLower() == nodeproperty.ToLower() || o.ParameterName.ToLower() == "@" + nodeproperty.ToLower()
                      select o).FirstOrDefault();
             //如果没有此属性,那么去除此节点
             //如果此属性中有值,那么也去除此节点
             if (p == null)
             {
                 sqlNode.ReplaceChild(AnalyzeChildSqlNode(node, parmeters), node);
             }
             else if (p.Value is DBNull == false)
             {
                 sqlNode.RemoveChild(node);
             }
             else
             {
                 sqlNode.ReplaceChild(AnalyzeChildSqlNode(node, parmeters), node);
             }
         }
         //去除isNotEmpty
         var isNotEmptyList = sqlNode.SelectNodes("isNotEmpty");
         foreach (XmlNode node in isNotEmptyList)
         {
             string nodeproperty = node.Attributes["property"].Value;
             var p = (from o in parmeters
                      where o.ParameterName.ToLower() == nodeproperty.ToLower() || o.ParameterName.ToLower() == "@" + nodeproperty.ToLower()
                      select o).FirstOrDefault();
             //如果没有此属性,那么去除此节点
             //如果此属性中无值,那么也去除此节点
             if (p == null || p.Value is DBNull)
             {
                 sqlNode.RemoveChild(node);
             }
             else
             {
                 sqlNode.ReplaceChild(AnalyzeChildSqlNode(node, parmeters), node);
             }
         }
         //去除isEqual
         var isEqualList = sqlNode.SelectNodes("isEqual");
         foreach (XmlNode node in isEqualList)
         {
             string nodeProperty = node.Attributes["property"].Value;
             string nodeValue = node.Attributes["compareValue"].Value;
             var p = (from o in parmeters
                      where o.ParameterName.ToLower() == nodeProperty.ToLower() || o.ParameterName.ToLower() == "@" + nodeProperty.ToLower()
                      select o).FirstOrDefault();
             //如果没有此属性,那么去除此节点
             //如果此属性中无值,那么也去除此节点
             if (p == null || p.Value.ToStringEx().ToLower().Equals(nodeValue.ToLower()) == false)
             {
                 sqlNode.RemoveChild(node);
             }
             else
             {
                 sqlNode.ReplaceChild(AnalyzeChildSqlNode(node, parmeters), node);
             }
         }
         //去除isNotEqual
         var isNotEqualList = sqlNode.SelectNodes("isNotEqual");
         foreach (XmlNode node in isNotEqualList)
         {
             string nodeProperty = node.Attributes["property"].Value;
             string nodeValue = node.Attributes["compareValue"].Value;
             var p = (from o in parmeters
                      where o.ParameterName.ToLower() == nodeProperty.ToLower() || o.ParameterName.ToLower() == "@" + nodeProperty.ToLower()
                      select o).FirstOrDefault();
             //如果没有此属性,那么去除此节点
             //如果此属性中无值,那么也去除此节点
             if (p == null || p.Value.ToStringEx().ToLower().Equals(nodeValue.ToLower()))
             {
                 sqlNode.RemoveChild(node);
             }
             else
             {
                 sqlNode.ReplaceChild(AnalyzeChildSqlNode(node, parmeters), node);
             }
         }
     }
     return sqlNode;
//.........这里部分代码省略.........
开发者ID:kevin-h-wang,项目名称:MVCStudy,代码行数:101,代码来源:FISqlHelper.cs

示例13: HandleCaseOfNoAncestor

        private static XmlNode HandleCaseOfNoAncestor(XmlMerger merger, XmlNode ours, XmlNode theirs)
        {
            var mainNodeStrategy = merger.MergeStrategies.GetElementStrategy(ours ?? theirs);
            var mergeSituation = merger.MergeSituation;
            var pathToFileInRepository = mergeSituation.PathToFileInRepository;
            if (ours == null)
            {
                // They added, we did nothing.
            // Route tested, but the MergeChildrenMethod adds the change report for us.
                // So, theory has it one can't get here from any normal place.
                // But, keep it, in case MergeChildrenMethod gets 'fixed'.
                merger.EventListener.ChangeOccurred(new XmlAdditionChangeReport(pathToFileInRepository, theirs));
                return theirs;
            }
            if (theirs == null)
            {
                // We added, they did nothing.
            // Route tested.
                merger.EventListener.ChangeOccurred(new XmlAdditionChangeReport(pathToFileInRepository, ours));
                return ours;
            }

            // Both added the special containing node.
            // Remove children nodes to see if main containing nodes are the same.
            if (XmlUtilities.AreXmlElementsEqual(ours, theirs))
            {
            // Route tested.
                // Same content.
                merger.EventListener.ChangeOccurred(new XmlBothAddedSameChangeReport(pathToFileInRepository, ours));
            }
            else
            {
                // Different content.
                var ourChild = GetElementChildren(ours).FirstOrDefault();
                var theirChild = GetElementChildren(theirs).FirstOrDefault();
                var ourClone = MakeClone(ours);
                var theirClone = MakeClone(theirs);
                if (XmlUtilities.AreXmlElementsEqual(ourClone, theirClone))
                {
                    // new main elements are the same, but not the contained child
                    merger.EventListener.ChangeOccurred(new XmlBothAddedSameChangeReport(pathToFileInRepository, ourClone));
                    if (ourChild == null && theirChild == null)
                        return ours; // Nobody added the child node.
                    if (ourChild == null)
                    {
                        merger.EventListener.ChangeOccurred(new XmlAdditionChangeReport(pathToFileInRepository, theirChild));
                        ours.AppendChild(theirChild);
                        return ours;
                    }
                    if (theirChild == null)
                    {
                        merger.EventListener.ChangeOccurred(new XmlAdditionChangeReport(pathToFileInRepository, ourChild));
                        return ours;
                    }
                    // both children exist, but are different.
                    var mergeStrategyForChild = merger.MergeStrategies.GetElementStrategy(ourChild);
                    if (merger.MergeSituation.ConflictHandlingMode == MergeOrder.ConflictHandlingModeChoices.WeWin)
                    {
                        // Do the clone thing on the two child nodes to see if the diffs are in the child or lower down.
                        var ourChildClone = MakeClone(ourChild);
                        var theirChildClone = MakeClone(theirChild);
                        if (XmlUtilities.AreXmlElementsEqual(ourChildClone, theirChildClone))
                        {
                            var ourChildReplacement = ourChild;
                            merger.MergeInner(ref ourChildReplacement, theirChild, null);
                            if (!ReferenceEquals(ourChild, ourChildReplacement))
                            {
                                ours.ReplaceChild(ours.OwnerDocument.ImportNode(ourChildReplacement, true), ourChild);
                            }
                        }
                        else
                        {
                            merger.ConflictOccurred(new BothAddedMainElementButWithDifferentContentConflict(ourChild.Name, ourChild, theirChild,
                                                                                                            mergeSituation, mergeStrategyForChild,
                                                                                                            mergeSituation.AlphaUserId));
                        }
                    }
                    else
                    {
                        // Do the clone thing on the two child nodes to see if the diffs are in the child or lower down.
                        var ourChildClone = MakeClone(ourChild);
                        var theirChildClone = MakeClone(theirChild);
                        if (XmlUtilities.AreXmlElementsEqual(ourChildClone, theirChildClone))
                        {
                            var ourChildReplacement = ourChild;
                            merger.MergeInner(ref ourChildReplacement, theirChild, null);
                            if (!ReferenceEquals(ourChild, ourChildReplacement))
                            {
                                ours.ReplaceChild(ours.OwnerDocument.ImportNode(ourChildReplacement, true), ourChild);
                            }
                        }
                        else
                        {
                            merger.ConflictOccurred(new BothAddedMainElementButWithDifferentContentConflict(ourChild.Name, ourChild, theirChild,
                                                                                                            mergeSituation, mergeStrategyForChild,
                                                                                                            mergeSituation.AlphaUserId));
                            ours.ReplaceChild(ours.OwnerDocument.ImportNode(theirChild, true), ourChild);
                        }
                    }
                    return ours;
//.........这里部分代码省略.........
开发者ID:JessieGriffin,项目名称:chorus,代码行数:101,代码来源:MergeLimitedChildrenService.cs

示例14: AppendOrOverrideChildNode

        //Append or override report child node
        private static void AppendOrOverrideChildNode(XmlNode newFather, XmlNode importChild, string name)
        {
            string value = importChild.Attributes[name].Value;
            bool duplicate = false;

            XmlNode old = null;
            foreach (XmlNode xn in newFather.ChildNodes)
            {
                if (xn.NodeType != XmlNodeType.Element)
                    continue;
                if (xn.Name != importChild.Name)
                    continue;
                if (xn.Attributes[name].Value == value)
                {
                    duplicate = true;
                    old = xn;
                    break;
                }
            }
            if (duplicate)
            {
                newFather.ReplaceChild(importChild.CloneNode(true), old);
            }
            else
            {
                newFather.AppendChild(importChild.CloneNode(true));
            }
        }
开发者ID:LiuXiaotian,项目名称:ProtocolTestFramework,代码行数:29,代码来源:ConfigurationReader.cs

示例15: InlineUses

 private static void InlineUses(IReadOnlyDictionary<string, XmlNode> map, XmlNode xmlNode)
 {
     var childNodes = xmlNode.ChildNodes;
     for (var i = 0; i < childNodes.Count; i++)
     {
         var childNode = childNodes[i];
         if (childNode.Name == "use")
         {
             var href = childNode.Attributes.GetNamedItem("href", "http://www.w3.org/1999/xlink");
             var hrefValue = href.Value;
             if (!hrefValue.StartsWith("#"))
             {
                 throw new UnsupportedFormatException("Only references within an SVG document are allowed.");
             }
             childNode.Attributes.Remove((XmlAttribute)href);
             hrefValue = hrefValue.Substring(1);
             childNode = CreateInline(childNode, map[hrefValue].CloneNode(true));
             xmlNode.ReplaceChild(childNode, childNodes[i]);
         }
         InlineUses(map, childNode);
     }
 }
开发者ID:rflechner,项目名称:SvgToVectorDrawableConverter,代码行数:22,代码来源:SvgUseElementInliner.cs


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