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


C# XmlNode.RemoveChild方法代码示例

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


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

示例1: findAndRemoveAmazonRR

 private static void findAndRemoveAmazonRR(string ns, XmlNode applicationNode, XmlDocument doc)
 {
     XmlElement e = FindElementForNameWithNamespace("receiver", "name", ns, "com.amazon.inapp.purchasing.ResponseReceiver", applicationNode);
     if (e != null)
     {
         applicationNode.RemoveChild(e);
     }
 }
开发者ID:ricna,项目名称:unity3d-store,代码行数:8,代码来源:ManifestTools.cs

示例2: foreach

        object IConfigurationSectionHandler.Create(object parent, object configContext, XmlNode section)
        {
            XmlDocument document = (XmlDocument)section.ParentNode;
             XmlNode fixedNode = document.CreateElement("hibernate-configuration");
             section.ParentNode.ReplaceChild(fixedNode, section);

             foreach (XmlNode node in section.ChildNodes)
             {
            fixedNode.AppendChild(section.RemoveChild(node));
             }
             return _originalHandler.Create(parent, configContext, fixedNode);
        }
开发者ID:remcoros,项目名称:NServiceBus,代码行数:12,代码来源:ConfigurationSectionHandler.cs

示例3: DeleteElem

 public void DeleteElem(NodesBase c)
 {
     root = doc.FirstChild;
     foreach (XmlNode elm in root.ChildNodes)
     {
         if (c.Elm == elm)
         {
             root.RemoveChild(elm);
             //elm.RemoveChild(elm);
         }
         else
         {
             if (DeleteChild(c.Elm, elm) == true) break;
         }
     }
 }
开发者ID:zebulon75018,项目名称:mauriceadmin,代码行数:16,代码来源:NodesBase.cs

示例4: RemoveElement

 /// <summary>
 /// Removes a name/value pair in appSettings collection
 /// </summary>
 /// <returns>A value indicating if the operation was successfull or not</returns>
 public bool RemoveElement(string elementKey)
 {
     try
     {
         XmlDocument ConfigToObject = new XmlDocument();
         LoadConfigToObject(ConfigToObject);
         appSettingsNode = ConfigToObject.SelectSingleNode("//appSettings");
         if (appSettingsNode == null)
             throw new System.InvalidOperationException("appSettings section not found");
         // XPath
         appSettingsNode.RemoveChild(appSettingsNode.SelectSingleNode("//add[@key='" + elementKey + "']"));
         SaveObjectToConfig(ConfigToObject, ConfigFileName);
         return true;
     }
     catch
     {
         return false;
     }
 }
开发者ID:chandru9279,项目名称:StarBase,代码行数:23,代码来源:ConfigFileManager.cs

示例5: Clean

        static void Clean(XmlNode node)
        {
            var count = node.ChildNodes.Count;
            for (var index = count - 1; index >= 0; --index)
            {
                var child = node.ChildNodes[index];
                if (child.NodeType != XmlNodeType.Element)
                {
                    node.RemoveChild(child);
                }
            }

            count = node.ChildNodes.Count;
            for (var index = 0; index < count; ++index)
            {
                var child = node.ChildNodes[index];
                Clean(child);
            }
        }
开发者ID:ifzz,项目名称:FDK,代码行数:19,代码来源:Protocol.cs

示例6: HTTPRedirect

        /// <summary>
        /// Transfers the message to the given endpoint using the HTTP-Redirect binding.
        /// </summary>
        protected static void HTTPRedirect(SAMLAction action, IDPEndPointElement endpoint, XmlNode message)
        {
            if (message.FirstChild is XmlDeclaration)
                message.RemoveChild(message.FirstChild);

            HttpRedirectBindingBuilder builder = new HttpRedirectBindingBuilder();

            if (action == SAMLAction.SAMLRequest)
                builder.Request = message.OuterXml;
            else
                builder.Response = message.OuterXml;

            builder.signingKey = IDPConfig.IDPCertificate.PrivateKey;

            UriBuilder url = new UriBuilder(endpoint.Url);
            url.Query = builder.ToQuery();

            HttpContext.Current.Response.Redirect(url.ToString(), true);                        
        }
开发者ID:fredrikhl,项目名称:OIOSAML,代码行数:22,代码来源:BaseHandler.cs

示例7: Sort

        public XmlNode Sort(XmlNode node)
        {
            var children = new List<XmlNode>();
            var sorting = GetSorting();

            foreach (XmlNode childNode in node.ChildNodes)
            {
                children.Add(childNode);

                SortChildren(childNode);
            }

            // Creates a copy of the sort order the elments were added in on the node
            var originalSortOrder = children.ToArray();

            children.Sort((x, y) =>
            {
                if (!sorting.ContainsKey(x.Name) || !sorting.ContainsKey(y.Name)) return 0;

                var xSort = sorting[x.Name];
                var ySort = sorting[y.Name];

                //General Position
                if (xSort.Position != ySort.Position) return xSort.Position.CompareTo(ySort.Position);
                //Sub-Position if positions are the same
                if (xSort.Level != ySort.Level) return xSort.Level.CompareTo(ySort.Level);

                //Relative Index based on the order the part was added
                return Array.IndexOf(originalSortOrder, x).CompareTo(Array.IndexOf(originalSortOrder, y));
            });

            for (var i = 0; i < node.ChildNodes.Count; i++)
            {
                node.RemoveChild(node.ChildNodes[i]);
            }

            foreach (var child in children)
            {
                node.AppendChild(child);
            }

            return node;
        }
开发者ID:sbakshi,项目名称:fluent-nhibernate,代码行数:43,代码来源:BaseXmlNodeSorter.cs

示例8: PreprocessParameters

        public XmlNode PreprocessParameters(NetReflectorTypeTable typeTable, XmlNode inputNode)
        {
            var dobNode = (from node in inputNode.ChildNodes
                               .OfType<XmlNode>()
                           where node.Name == "dob"
                           select node).SingleOrDefault();
            if (dobNode != null)
            {
                var dob = DateTime.Parse(dobNode.InnerText);
                inputNode.RemoveChild(dobNode);
                var ageNode = inputNode.OwnerDocument.CreateElement("age");
                ageNode.InnerText = Convert.ToInt32(
                    (DateTime.Now - dob).TotalDays / 365)
                    .ToString();
                inputNode.AppendChild(ageNode);
            }

            return inputNode;
        }
开发者ID:BiYiTuan,项目名称:CruiseControl.NET,代码行数:19,代码来源:DemoTask.cs

示例9: SortChildNodes

		private static void SortChildNodes(XmlNode node)
		{

			var sl = new SortedList<string, XmlNode>();
			if (node.Attributes != null)
			{
				int i = 0;
				foreach (XmlNode n in node.ChildNodes)
					sl[n.OuterXml + "\"" + i++] = n;
				foreach (var n in sl.Values)
					node.RemoveChild(n);

				foreach (var n in sl.Values)
					node.AppendChild(n);
			}

			foreach (XmlNode chNode in node.ChildNodes)
				SortAttribs(chNode);
		}
开发者ID:Kalyan00,项目名称:proj,代码行数:19,代码来源:Program.cs

示例10: DeleteAlbumsWithPriceLessThan20

        private static void DeleteAlbumsWithPriceLessThan20(XmlNode node)
        {
            var nodeList = node.ChildNodes;
            List<XmlNode> nodesToDelete = new List<XmlNode>();

            foreach (XmlNode album in nodeList)
            {
                float currentAlbumPrice = float.Parse(album["price"].InnerText, CultureInfo.InvariantCulture);

                if (currentAlbumPrice < 20.0)
                {
                    nodesToDelete.Add(album);
                }
            }

            foreach (XmlNode album in nodesToDelete)
            {
                Console.WriteLine("Album called \"{0}\"'s price is {1} so it was deleted.", album["name"].InnerText, album["price"].InnerText);
                node.RemoveChild(album);
            }
        }
开发者ID:juvemar,项目名称:Databases,代码行数:21,代码来源:DeleteAlbums.cs

示例11: WriteTo

        public override System.Xml.XmlNode WriteTo(XmlNode parent)
        {
            XmlElement stringsElement = parent.SelectSingleNode("child::" + name) as XmlElement;
            if (stringsElement != null)
            {
                parent.RemoveChild(stringsElement);
            }

            stringsElement = parent.OwnerDocument.CreateElement(name);
            parent.AppendChild(stringsElement);

            if (values != null)
            {
                foreach (string item in values)
                {
                    XmlElement itemElement = parent.OwnerDocument.CreateElement("Item");
                    itemElement.InnerText = item;
                    stringsElement.AppendChild(itemElement);
                }
            }

            return null;
        }
开发者ID:bashocz,项目名称:MapperConfigModule,代码行数:23,代码来源:StringListXmlElement.cs

示例12: AddTypes

	static void AddTypes (XmlNode dest, XmlDocument source, string sourceDirectory)
	{
		var types = source.SelectSingleNode ("/Overview/Types");
		if (types == null)
			return;
		foreach (XmlNode ns in types.ChildNodes) {
			var n = ns.Attributes ["Name"].Value;
			var nsd = dest.SelectSingleNode (string.Format ("Namespace[@Name='{0}']", n));
			if (nsd == null) {
				nsd = dest.OwnerDocument.CreateElement ("Namespace");
				AddAttribute (nsd, "Name", n);
				dest.AppendChild (nsd);
			}
			foreach (XmlNode t in ns.ChildNodes) {
				if (!TypeInVersions (sourceDirectory, n, t))
					continue;
				var c = dest.OwnerDocument.ImportNode (t, true);
				AddAttribute (c, "SourceDirectory", sourceDirectory);
				nsd.AppendChild (c);
			}
			if (nsd.ChildNodes.Count == 0)
				dest.RemoveChild (nsd);
		}
	}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:24,代码来源:monodocs2html.cs

示例13: ParseInstallNode

		private void ParseInstallNode(XmlNode installNode)
		{
			XmlNodeList components = installNode.SelectNodes("component");
			if (components.Count == 0)
			{
				//remove parent install node
				installNode.ParentNode.RemoveChild(installNode);
				ProceedUnattendedSetup();
			}
			else
			{
				//remove current node and start installation
				XmlElement componentNode = (XmlElement)components[0];
				string componentCode = componentNode.GetAttribute("code");
				string componentVersion = componentNode.GetAttribute("version");
				string xml = componentNode.InnerXml;
				installNode.RemoveChild(componentNode);

				if (!string.IsNullOrEmpty(componentCode))
				{
					ScopeNode componentsNode = scopeTree.Nodes[0] as ScopeNode;
					scopeTree.SelectedNode = componentsNode;
					ComponentsControl ctrl = componentsNode.ResultView as ComponentsControl;
					ctrl.InstallComponent(componentCode, componentVersion, xml);
				}
			}
		}
开发者ID:jordan49,项目名称:websitepanel,代码行数:27,代码来源:ApplicationForm.cs

示例14: SetNodeText

 /**
 * Sets the text of this node. All the child's node are deleted and a new
 * child text node is created.
 * @param domDocument the <CODE>Document</CODE> that contains the node
 * @param n the <CODE>Node</CODE> to add the text to
 * @param value the text to add
 */
 public bool SetNodeText(XmlDocument domDocument, XmlNode n, String value)
 {
     if (n == null)
         return false;
     XmlNode nc = null;
     while ((nc = n.FirstChild) != null) {
         n.RemoveChild(nc);
     }
     n.AppendChild(domDocument.CreateTextNode(value));
     return true;
 }
开发者ID:mapo80,项目名称:iTextSharp-Monotouch,代码行数:18,代码来源:XmpReader.cs

示例15: RemoveAllNodes

 private static void RemoveAllNodes(XmlDocument doc, XmlNode targetsNode, string xpath)
 {
     var matchingNodes = doc.SelectNodes(xpath);
     foreach (XmlNode node in matchingNodes)
         targetsNode.RemoveChild(node);
 }
开发者ID:rajdotnet,项目名称:aws-sdk-net,代码行数:6,代码来源:FxCop.cs


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