RemoveChild() public method

public RemoveChild ( XmlNode child ) : XmlNode
child XmlNode
return XmlNode
示例#1
0
 public bool DisableRewriter(string configPath)
 {
     try
     {
         XmlDocument xDoc = new XmlDocument();
         xDoc.Load(configPath);
         if (xDoc != null)
         {
             System.Xml.XmlNode xRoot = xDoc.DocumentElement;
             System.Xml.XmlNode xNode = xRoot.SelectSingleNode("//system.webServer/modules");
             if (xNode != null)
             {
                 bool isInstalled = false;
                 foreach (XmlNode n in xNode.ChildNodes)
                 {
                     if (n.Attributes["name"].Value == "ForumsReWriter")
                     {
                         xNode.RemoveChild(n);
                         isInstalled = true;
                         break;
                     }
                 }
                 if (isInstalled)
                 {
                     xDoc.Save(configPath);
                 }
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
示例#2
0
 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);
     }
 }
        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);
        }
示例#4
0
        /// <summary>
        /// 增加一个历史审批记录

        /// </summary>
        /// <param name="Name"></param>
        /// <param name="DomainAccount"></param>
        /// <param name="ApprovalResult"></param>
        /// <param name="ApprovalComment"></param>
        /// <param name="ActivityName"></param>
        public void AddApproval(string Name, string DomainAccount, string ApprovalResult, string ApprovalComment, string ActivityName)
        {
            string strDomainAccount = DomainAccount;

            strDomainAccount = strDomainAccount.ToLower();
            strDomainAccount = strDomainAccount.Replace("centaline\\\\", "");

            System.Xml.XmlNode ApprovalNode = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "Approval", "");

            System.Xml.XmlNode tmp = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "Name", "");
            tmp.InnerText = Name;
            ApprovalNode.AppendChild(tmp);

            tmp           = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "DomainAccount", "");
            tmp.InnerText = strDomainAccount;
            ApprovalNode.AppendChild(tmp);

            tmp           = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "ApprovalResult", "");
            tmp.InnerText = ApprovalResult;
            ApprovalNode.AppendChild(tmp);

            tmp           = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "ApprovalComment", "");
            tmp.InnerText = ApprovalComment;
            ApprovalNode.AppendChild(tmp);

            tmp           = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "ApprovalTime", "");
            tmp.InnerText = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            ApprovalNode.AppendChild(tmp);

            tmp           = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "ActivityName", "");
            tmp.InnerText = ActivityName;
            ApprovalNode.AppendChild(tmp);

            System.Xml.XmlNode pobj = this.mobj.SelectSingleNode("Root/Approvals");
            if (pobj == null)
            {
                throw new Exception("没有找到XML节点[Root/Approvals],请检查数据格式定义是否正确!");
            }
            else
            {
                tmp = pobj.FirstChild;
                if (tmp != null)
                {
                    if (tmp.InnerText.Trim() == "")     //如果<Approval></Approval>为空则要删除掉
                    {
                        pobj.RemoveChild(tmp);
                    }
                }
                pobj.AppendChild(ApprovalNode);
            }
        }
示例#5
0
        /// <summary>
        /// 设置最后审批历史记录

        /// </summary>
        /// <param name="Name"></param>
        /// <param name="DomainAccount"></param>
        /// <param name="ApprovalResult"></param>
        /// <param name="ApprovalComment"></param>
        /// <param name="ActivityName"></param>
        public void SetLastApproval(string Name, string DomainAccount, string ApprovalResult, string ApprovalComment, string ActivityName)
        {
            string strDomainAccount = DomainAccount;

            strDomainAccount = GetShortADUserID(strDomainAccount);

            System.Xml.XmlNode ApprovalNode = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "Approval", "");

            System.Xml.XmlNode tmp = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "Name", "");
            tmp.InnerText = Name;
            ApprovalNode.AppendChild(tmp);

            tmp           = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "DomainAccount", "");
            tmp.InnerText = strDomainAccount;
            ApprovalNode.AppendChild(tmp);

            tmp           = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "ApprovalResult", "");
            tmp.InnerText = ApprovalResult;
            ApprovalNode.AppendChild(tmp);

            tmp           = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "ApprovalComment", "");
            tmp.InnerText = ApprovalComment;
            ApprovalNode.AppendChild(tmp);

            tmp           = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "ApprovalTime", "");
            tmp.InnerText = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            ApprovalNode.AppendChild(tmp);

            tmp           = this.mobj.CreateNode(System.Xml.XmlNodeType.Element, "ActivityName", "");
            tmp.InnerText = ActivityName;
            ApprovalNode.AppendChild(tmp);

            System.Xml.XmlNode pobj = this.mobj.SelectSingleNode("Root/Approvals");
            if (pobj == null)
            {
                throw new Exception("没有找到XML节点[Root/Approvals],请检查数据格式定义是否正确!");
            }
            else
            {
                tmp = pobj.FirstChild;
                if (tmp != null)
                {
                    if (tmp.InnerText.Trim() == "")
                    {
                        pobj.RemoveChild(tmp);
                    }
                }
                pobj.RemoveAll();               //清空旧的
                pobj.AppendChild(ApprovalNode); //加入新的
            }
        }
示例#6
0
        public static void DeleteExpress(string name)
        {
            XmlDocument xmlNode = GetXmlNode();

            System.Xml.XmlNode node = xmlNode.SelectSingleNode("companys");
            foreach (System.Xml.XmlNode node2 in node.ChildNodes)
            {
                if (node2.Attributes["name"].Value == name)
                {
                    node.RemoveChild(node2);
                    break;
                }
            }
            xmlNode.Save(path);
        }
示例#7
0
 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;
         }
     }
 }
示例#8
0
 private void RemoveUnsupportedNodes(System.Xml.XmlNode xmlNode)
 {
     System.Xml.XmlNode firstChild = xmlNode.FirstChild;
     while (firstChild != null)
     {
         if (firstChild.NodeType == XmlNodeType.Comment)
         {
             System.Xml.XmlNode oldChild = firstChild;
             firstChild = firstChild.NextSibling;
             xmlNode.RemoveChild(oldChild);
         }
         else
         {
             this.RemoveUnsupportedNodes(firstChild);
             firstChild = firstChild.NextSibling;
         }
     }
 }
        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;
        }
示例#10
0
 /// <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;
     }
 }
示例#11
0
        public void Remove(string Key)
        {
            // Load the config file into the XML DOM.
            XmlDocument xmlDom = GetXmlDocument();

            // get parent & child
            System.Xml.XmlNode node       = xmlDom.SelectSingleNode("configuration/" + m_Section + "/add[@key='" + Key + "']");
            System.Xml.XmlNode parentNode = xmlDom.SelectSingleNode("configuration/" + m_Section);

            // delete the node
            parentNode.RemoveChild(node);

            // Save the modified config file.
            xmlDom.Save(m_ConfigFile);

            m_Settings.Remove(Key);

            return;
        }
示例#12
0
        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;
        }
示例#13
0
文件: Protocol.cs 项目: ifzz/FDK
        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);
            }
        }
示例#14
0
文件: Program.cs 项目: Kalyan00/proj
		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);
		}
示例#15
0
        /// <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);                        
        }
示例#16
0
        private void grdHeaderMenu_RowDeleting(object sender, System.Web.UI.WebControls.GridViewDeleteEventArgs e)
        {
            int    num      = (int)this.grdMyHeaderMenu.DataKeys[e.RowIndex].Value;
            string filename = System.Web.HttpContext.Current.Request.MapPath(Globals.ApplicationPath + string.Format("/Templates/sites/" + Hidistro.Membership.Context.HiContext.Current.User.UserId.ToString() + "/{0}/config/HeaderMenu.xml", this.themName));

            System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
            xmlDocument.Load(filename);
            System.Xml.XmlNode     xmlNode    = xmlDocument.SelectSingleNode("root");
            System.Xml.XmlNodeList childNodes = xmlNode.ChildNodes;
            foreach (System.Xml.XmlNode xmlNode2 in childNodes)
            {
                if (xmlNode2.Attributes["Id"].Value == num.ToString())
                {
                    xmlNode.RemoveChild(xmlNode2);
                    break;
                }
            }
            xmlDocument.Save(filename);
            this.BindHeaderMenu();
        }
示例#17
0
        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);
            }
        }
        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;
        }
示例#19
0
        /// <summary>
        /// 保存报警配置到本地文件
        /// </summary>
        /// <param name="flag">性质、种类、测点</param>
        /// <param name="dt"></param>
        public static bool SaveConfig(int flag, List <ClientAlarmItems> list)
        {
            bool b = true;

            try
            {
                _docoment.Load(_filePath);
                System.Xml.XmlNode node = null;
                switch (flag)
                {
                case 1:    //性质
                    node = _docoment.SelectSingleNode("//AlarmSettings/PropertySetting");
                    break;

                case 2:    //种类
                    node = _docoment.SelectSingleNode("//AlarmSettings/ClassSetting");
                    break;

                case 3:    //测点
                    node = _docoment.SelectSingleNode("//AlarmSettings/PointSetting");
                    break;

                case 4:    //设备类型
                    node = _docoment.SelectSingleNode("//AlarmSettings/DevSetting");
                    break;

                default:
                    break;
                }
                //先删除代码相同的报警设置
                if (list.Count > 0)//增加判断  20180113
                {
                    for (int i = 0; i < node.ChildNodes.Count;)
                    {
                        if (node.ChildNodes[i].Attributes["code"].Value == list[0].code)
                        {
                            node.RemoveChild(node.ChildNodes[i]);
                            continue;
                        }
                        i++;
                    }
                }
                bool isContentFlag = false;
                foreach (var r in list)
                {
                    if (!string.IsNullOrEmpty(r.alarmShow) && r.alarmShow != "无设置")//增加报警配置判断,如果未配置报警,则不保存  20171228
                    {
                        isContentFlag = true;
                    }
                }
                if (isContentFlag)
                {
                    //再新建该代码的报警设置
                    foreach (var r in list)
                    {
                        XmlElement el = _docoment.CreateElement("Item");
                        el.SetAttribute("code", r.code);
                        el.SetAttribute("name", r.name);
                        el.SetAttribute("alarmType", r.alarmType);
                        el.SetAttribute("alarmCode", r.alarmCode);
                        el.SetAttribute("alarmShow", r.alarmShow == "无设置" ? "" : r.alarmShow);
                        node.AppendChild(el);
                    }
                }
                _docoment.Save(_filePath);
            }
            catch (Exception ex)
            {
                //写日志、抛异常等
                LogHelper.Error("保存报警配置到本地文件 发生异常", ex);
                b = false;
            }
            return(b);
        }
示例#20
0
文件: XmlNode.cs 项目: jnm2/corefx
        // Adds the specified node to the end of the list of children of this node.
        public virtual XmlNode AppendChild(XmlNode newChild)
        {
            XmlDocument thisDoc = OwnerDocument;

            if (thisDoc == null)
            {
                thisDoc = this as XmlDocument;
            }
            if (!IsContainer)
            {
                throw new InvalidOperationException(SR.Xdom_Node_Insert_Contain);
            }

            if (this == newChild || AncestorNode(newChild))
            {
                throw new ArgumentException(SR.Xdom_Node_Insert_Child);
            }

            if (newChild.ParentNode != null)
            {
                newChild.ParentNode.RemoveChild(newChild);
            }

            XmlDocument childDoc = newChild.OwnerDocument;

            if (childDoc != null && childDoc != thisDoc && childDoc != this)
            {
                throw new ArgumentException(SR.Xdom_Node_Insert_Context);
            }

            // special case for doc-fragment.
            if (newChild.NodeType == XmlNodeType.DocumentFragment)
            {
                XmlNode first = newChild.FirstChild;
                XmlNode node  = first;
                while (node != null)
                {
                    XmlNode next = node.NextSibling;
                    newChild.RemoveChild(node);
                    AppendChild(node);
                    node = next;
                }
                return(first);
            }

            if (!(newChild is XmlLinkedNode) || !IsValidChildType(newChild.NodeType))
            {
                throw new InvalidOperationException(SR.Xdom_Node_Insert_TypeConflict);
            }


            if (!CanInsertAfter(newChild, LastChild))
            {
                throw new InvalidOperationException(SR.Xdom_Node_Insert_Location);
            }

            string newChildValue         = newChild.Value;
            XmlNodeChangedEventArgs args = GetEventArgs(newChild, newChild.ParentNode, this, newChildValue, newChildValue, XmlNodeChangedAction.Insert);

            if (args != null)
            {
                BeforeEvent(args);
            }

            XmlLinkedNode refNode = LastNode;
            XmlLinkedNode newNode = (XmlLinkedNode)newChild;

            if (refNode == null)
            {
                newNode.next = newNode;
                LastNode     = newNode;
                newNode.SetParent(this);
            }
            else
            {
                newNode.next = refNode.next;
                refNode.next = newNode;
                LastNode     = newNode;
                newNode.SetParent(this);

                if (refNode.IsText)
                {
                    if (newNode.IsText)
                    {
                        NestTextNodes(refNode, newNode);
                    }
                }
            }

            if (args != null)
            {
                AfterEvent(args);
            }

            return(newNode);
        }
示例#21
0
文件: XmlNode.cs 项目: jnm2/corefx
        // Inserts the specified node immediately before the specified reference node.
        public virtual XmlNode InsertBefore(XmlNode newChild, XmlNode refChild)
        {
            if (this == newChild || AncestorNode(newChild))
            {
                throw new ArgumentException(SR.Xdom_Node_Insert_Child);
            }

            if (refChild == null)
            {
                return(AppendChild(newChild));
            }

            if (!IsContainer)
            {
                throw new InvalidOperationException(SR.Xdom_Node_Insert_Contain);
            }

            if (refChild.ParentNode != this)
            {
                throw new ArgumentException(SR.Xdom_Node_Insert_Path);
            }

            if (newChild == refChild)
            {
                return(newChild);
            }

            XmlDocument childDoc = newChild.OwnerDocument;
            XmlDocument thisDoc  = OwnerDocument;

            if (childDoc != null && childDoc != thisDoc && childDoc != this)
            {
                throw new ArgumentException(SR.Xdom_Node_Insert_Context);
            }

            if (!CanInsertBefore(newChild, refChild))
            {
                throw new InvalidOperationException(SR.Xdom_Node_Insert_Location);
            }

            if (newChild.ParentNode != null)
            {
                newChild.ParentNode.RemoveChild(newChild);
            }

            // special case for doc-fragment.
            if (newChild.NodeType == XmlNodeType.DocumentFragment)
            {
                XmlNode first = newChild.FirstChild;
                XmlNode node  = first;
                if (node != null)
                {
                    newChild.RemoveChild(node);
                    InsertBefore(node, refChild);
                    // insert the rest of the children after this one.
                    InsertAfter(newChild, node);
                }
                return(first);
            }

            if (!(newChild is XmlLinkedNode) || !IsValidChildType(newChild.NodeType))
            {
                throw new InvalidOperationException(SR.Xdom_Node_Insert_TypeConflict);
            }

            XmlLinkedNode newNode = (XmlLinkedNode)newChild;
            XmlLinkedNode refNode = (XmlLinkedNode)refChild;

            string newChildValue         = newChild.Value;
            XmlNodeChangedEventArgs args = GetEventArgs(newChild, newChild.ParentNode, this, newChildValue, newChildValue, XmlNodeChangedAction.Insert);

            if (args != null)
            {
                BeforeEvent(args);
            }

            if (refNode == FirstChild)
            {
                newNode.next  = refNode;
                LastNode.next = newNode;
                newNode.SetParent(this);

                if (newNode.IsText)
                {
                    if (refNode.IsText)
                    {
                        NestTextNodes(newNode, refNode);
                    }
                }
            }
            else
            {
                XmlLinkedNode prevNode = (XmlLinkedNode)refNode.PreviousSibling;

                newNode.next  = refNode;
                prevNode.next = newNode;
                newNode.SetParent(this);

                if (prevNode.IsText)
                {
                    if (newNode.IsText)
                    {
                        NestTextNodes(prevNode, newNode);
                        if (refNode.IsText)
                        {
                            NestTextNodes(newNode, refNode);
                        }
                    }
                    else
                    {
                        if (refNode.IsText)
                        {
                            UnnestTextNodes(prevNode, refNode);
                        }
                    }
                }
                else
                {
                    if (newNode.IsText)
                    {
                        if (refNode.IsText)
                        {
                            NestTextNodes(newNode, refNode);
                        }
                    }
                }
            }

            if (args != null)
            {
                AfterEvent(args);
            }

            return(newNode);
        }
示例#22
0
		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);
				}
			}
		}
示例#23
0
 private XmlNode modifyNode(XmlDocument mergedDocument, XmlNode destinationParentNode, XmlNode nodeToModify, bool remove)
 {
     XmlAttribute keyAttribute = getKeyAttribute(nodeToModify);
     XmlNode targetNode = locateTargetNode(destinationParentNode, nodeToModify, keyAttribute);
     if (targetNode == null)
     {
         if (remove) return null;
         if (destinationParentNode.NodeType == XmlNodeType.Document)
         {
             throw new MultipleRootNodesException();
         }
         targetNode = destinationParentNode.AppendChild(mergedDocument.CreateNode(XmlNodeType.Element, nodeToModify.Name, String.Empty));
         Log.LogMessage(MessageImportance.Low, "Created node '{0}'", getFullPathOfNode(targetNode));
         if (keyAttribute != null)
         {
             XmlAttribute keyAttributeOnNewNode = targetNode.Attributes.Append(mergedDocument.CreateAttribute(keyAttribute.LocalName));
             keyAttributeOnNewNode.Value = keyAttribute.Value;
         }
     }
     else
     {
         if (remove)
         {
             Log.LogMessage(MessageImportance.Normal, "Removing node '{0}'", getFullPathOfNode(targetNode));
             destinationParentNode.RemoveChild(targetNode);
         }
     }
     return targetNode;
 }
示例#24
0
        /// <summary>
        /// WriteRaw writes out the given string "unescaped", in other words it better be well formed XML markup.
        /// So for the XmlNodeWriter we parse this string and build the resulting tree, so it maps to setting the
        /// InnerXml property.
        /// </summary>
        /// <param name="data"></param>
        public override void WriteRaw(string data)
        {
            if (data.IndexOf("<") < 0)
            {
                WriteString(data);
                return;
            }

            switch (state)
            {
            case WriteState.Start:
                goto case WriteState.Content;

            case WriteState.Prolog:
                goto case WriteState.Content;

            case WriteState.Element:
                state = WriteState.Content;
                goto case WriteState.Content;

            case WriteState.Attribute:
            {
                ArrayList saved = new ArrayList();
                if (ca.HasChildNodes)
                {
                    while (ca.FirstChild != null)
                    {
                        saved.Add(ca.FirstChild);
                        ca.RemoveChild(ca.FirstChild);
                    }
                }
                ca.InnerXml = data;
                for (int i = saved.Count - 1; i >= 0; i--)
                {
                    ca.PrependChild((XmlNode)saved[i]);
                }
            }
            break;

            case WriteState.Content:
            {
                ArrayList saved = new ArrayList();
                if (current.HasChildNodes)
                {
                    while (current.FirstChild != null)
                    {
                        saved.Add(current.FirstChild);
                        current.RemoveChild(current.FirstChild);
                    }
                }
                current.InnerXml = data;
                for (int i = saved.Count - 1; i >= 0; i--)
                {
                    current.PrependChild((XmlNode)saved[i]);
                }
                state = WriteState.Content;
            }
            break;

            case WriteState.Closed:
                throw new InvalidOperationException("Writer is closed");
            }
        }
 public virtual XmlNode AppendChild(XmlNode newChild)
 {
     XmlDocument ownerDocument = this.OwnerDocument;
     if (ownerDocument == null)
     {
         ownerDocument = this as XmlDocument;
     }
     if (!this.IsContainer)
     {
         throw new InvalidOperationException(Res.GetString("Xdom_Node_Insert_Contain"));
     }
     if ((this == newChild) || this.AncestorNode(newChild))
     {
         throw new ArgumentException(Res.GetString("Xdom_Node_Insert_Child"));
     }
     if (newChild.ParentNode != null)
     {
         newChild.ParentNode.RemoveChild(newChild);
     }
     XmlDocument document2 = newChild.OwnerDocument;
     if (((document2 != null) && (document2 != ownerDocument)) && (document2 != this))
     {
         throw new ArgumentException(Res.GetString("Xdom_Node_Insert_Context"));
     }
     if (newChild.NodeType == XmlNodeType.DocumentFragment)
     {
         XmlNode nextSibling;
         XmlNode firstChild = newChild.FirstChild;
         for (XmlNode node2 = firstChild; node2 != null; node2 = nextSibling)
         {
             nextSibling = node2.NextSibling;
             newChild.RemoveChild(node2);
             this.AppendChild(node2);
         }
         return firstChild;
     }
     if (!(newChild is XmlLinkedNode) || !this.IsValidChildType(newChild.NodeType))
     {
         throw new InvalidOperationException(Res.GetString("Xdom_Node_Insert_TypeConflict"));
     }
     if (!this.CanInsertAfter(newChild, this.LastChild))
     {
         throw new InvalidOperationException(Res.GetString("Xdom_Node_Insert_Location"));
     }
     string oldValue = newChild.Value;
     XmlNodeChangedEventArgs args = this.GetEventArgs(newChild, newChild.ParentNode, this, oldValue, oldValue, XmlNodeChangedAction.Insert);
     if (args != null)
     {
         this.BeforeEvent(args);
     }
     XmlLinkedNode lastNode = this.LastNode;
     XmlLinkedNode nextNode = (XmlLinkedNode) newChild;
     if (lastNode == null)
     {
         nextNode.next = nextNode;
         this.LastNode = nextNode;
         nextNode.SetParent(this);
     }
     else
     {
         nextNode.next = lastNode.next;
         lastNode.next = nextNode;
         this.LastNode = nextNode;
         nextNode.SetParent(this);
         if (lastNode.IsText && nextNode.IsText)
         {
             NestTextNodes(lastNode, nextNode);
         }
     }
     if (args != null)
     {
         this.AfterEvent(args);
     }
     return nextNode;
 }
 public virtual XmlNode InsertBefore(XmlNode newChild, XmlNode refChild)
 {
     if ((this == newChild) || this.AncestorNode(newChild))
     {
         throw new ArgumentException(Res.GetString("Xdom_Node_Insert_Child"));
     }
     if (refChild == null)
     {
         return this.AppendChild(newChild);
     }
     if (!this.IsContainer)
     {
         throw new InvalidOperationException(Res.GetString("Xdom_Node_Insert_Contain"));
     }
     if (refChild.ParentNode != this)
     {
         throw new ArgumentException(Res.GetString("Xdom_Node_Insert_Path"));
     }
     if (newChild == refChild)
     {
         return newChild;
     }
     XmlDocument ownerDocument = newChild.OwnerDocument;
     XmlDocument document2 = this.OwnerDocument;
     if (((ownerDocument != null) && (ownerDocument != document2)) && (ownerDocument != this))
     {
         throw new ArgumentException(Res.GetString("Xdom_Node_Insert_Context"));
     }
     if (!this.CanInsertBefore(newChild, refChild))
     {
         throw new InvalidOperationException(Res.GetString("Xdom_Node_Insert_Location"));
     }
     if (newChild.ParentNode != null)
     {
         newChild.ParentNode.RemoveChild(newChild);
     }
     if (newChild.NodeType == XmlNodeType.DocumentFragment)
     {
         XmlNode firstChild = newChild.FirstChild;
         XmlNode oldChild = firstChild;
         if (oldChild != null)
         {
             newChild.RemoveChild(oldChild);
             this.InsertBefore(oldChild, refChild);
             this.InsertAfter(newChild, oldChild);
         }
         return firstChild;
     }
     if (!(newChild is XmlLinkedNode) || !this.IsValidChildType(newChild.NodeType))
     {
         throw new InvalidOperationException(Res.GetString("Xdom_Node_Insert_TypeConflict"));
     }
     XmlLinkedNode prevNode = (XmlLinkedNode) newChild;
     XmlLinkedNode nextNode = (XmlLinkedNode) refChild;
     string oldValue = newChild.Value;
     XmlNodeChangedEventArgs args = this.GetEventArgs(newChild, newChild.ParentNode, this, oldValue, oldValue, XmlNodeChangedAction.Insert);
     if (args != null)
     {
         this.BeforeEvent(args);
     }
     if (nextNode == this.FirstChild)
     {
         prevNode.next = nextNode;
         this.LastNode.next = prevNode;
         prevNode.SetParent(this);
         if (prevNode.IsText && nextNode.IsText)
         {
             NestTextNodes(prevNode, nextNode);
         }
     }
     else
     {
         XmlLinkedNode previousSibling = (XmlLinkedNode) nextNode.PreviousSibling;
         prevNode.next = nextNode;
         previousSibling.next = prevNode;
         prevNode.SetParent(this);
         if (previousSibling.IsText)
         {
             if (prevNode.IsText)
             {
                 NestTextNodes(previousSibling, prevNode);
                 if (nextNode.IsText)
                 {
                     NestTextNodes(prevNode, nextNode);
                 }
             }
             else if (nextNode.IsText)
             {
                 UnnestTextNodes(previousSibling, nextNode);
             }
         }
         else if (prevNode.IsText && nextNode.IsText)
         {
             NestTextNodes(prevNode, nextNode);
         }
     }
     if (args != null)
     {
         this.AfterEvent(args);
     }
     return prevNode;
 }
示例#27
0
        // Adds the specified node to the end of the list of children of this node.
        public virtual XmlNode AppendChild(XmlNode newChild)
        {
            XmlDocument thisDoc = OwnerDocument;
            if (thisDoc == null)
            {
                thisDoc = this as XmlDocument;
            }
            if (!IsContainer)
                throw new InvalidOperationException(SR.Xdom_Node_Insert_Contain);

            if (this == newChild || AncestorNode(newChild))
                throw new ArgumentException(SR.Xdom_Node_Insert_Child);

            if (newChild.ParentNode != null)
                newChild.ParentNode.RemoveChild(newChild);

            XmlDocument childDoc = newChild.OwnerDocument;
            if (childDoc != null && childDoc != thisDoc && childDoc != this)
                throw new ArgumentException(SR.Xdom_Node_Insert_Context);

            // special case for doc-fragment.
            if (newChild.NodeType == XmlNodeType.DocumentFragment)
            {
                XmlNode first = newChild.FirstChild;
                XmlNode node = first;
                while (node != null)
                {
                    XmlNode next = node.NextSibling;
                    newChild.RemoveChild(node);
                    AppendChild(node);
                    node = next;
                }
                return first;
            }

            if (!(newChild is XmlLinkedNode) || !IsValidChildType(newChild.NodeType))
                throw new InvalidOperationException(SR.Xdom_Node_Insert_TypeConflict);


            if (!CanInsertAfter(newChild, LastChild))
                throw new InvalidOperationException(SR.Xdom_Node_Insert_Location);

            string newChildValue = newChild.Value;
            XmlNodeChangedEventArgs args = GetEventArgs(newChild, newChild.ParentNode, this, newChildValue, newChildValue, XmlNodeChangedAction.Insert);

            if (args != null)
                BeforeEvent(args);

            XmlLinkedNode refNode = LastNode;
            XmlLinkedNode newNode = (XmlLinkedNode)newChild;

            if (refNode == null)
            {
                newNode.next = newNode;
                LastNode = newNode;
                newNode.SetParent(this);
            }
            else
            {
                newNode.next = refNode.next;
                refNode.next = newNode;
                LastNode = newNode;
                newNode.SetParent(this);

                if (refNode.IsText)
                {
                    if (newNode.IsText)
                    {
                        NestTextNodes(refNode, newNode);
                    }
                }
            }

            if (args != null)
                AfterEvent(args);

            return newNode;
        }
示例#28
0
        /// <summary>
        /// In version 2.5.3 and below, external players were defined individually by MediaType.
        /// Now you define a player once and select multipe MediaTypes
        /// This will attempt to merge the multiple definitions into a single one
        /// </summary>
        private void MergeExternalPlayers(XmlDocument doc, XmlNode externalPlayersNode)
        {
            XmlNodeList nodes = externalPlayersNode.SelectNodes("ExternalPlayer");

            bool merged = false;

            // Loop through each node starting with the last and counting down
            for (int i = 1; i < nodes.Count; i++ )
            {
                XmlNode node = nodes[i];

                // Get the command and MediaType
                string command = node.SelectSingleNode("Command").InnerText.ToLower();
                string mediaType = node.SelectSingleNode("MediaTypes/MediaType").InnerText;

                XmlNode nodeToMergeWith = null;

                // Now go through each one from the beginning and see if there's another player using the same command
                for (int j = 0; j < i; j++)
                {
                    var testNode = nodes[j];

                    // Found a match
                    if (testNode.SelectSingleNode("Command").InnerText.ToLower() == command)
                    {
                        nodeToMergeWith = testNode;
                        break;
                    }
                }

                // If we found a match, add the MediaType to the one we found and delete the current node
                if (nodeToMergeWith != null)
                {
                    XmlElement mediaTypeElem = doc.CreateElement("MediaType");
                    mediaTypeElem.InnerText = mediaType;
                    nodeToMergeWith.SelectSingleNode("MediaTypes").AppendChild(mediaTypeElem);
                    externalPlayersNode.RemoveChild(node);
                    merged = true;
                    break;
                }
            }

            // Keep going until there are no more merges
            if (merged)
            {
                MergeExternalPlayers(doc, externalPlayersNode);
            }
        }
示例#29
0
		/// <summary>
		/// Updates the child nodes of "parentNode" by using the fields from a datatable.
		/// </summary>
		/// <param name="parentNode"></param>
		/// <param name="table"></param>
		/// <param name="keyField">The column name of the datatable that acts as a primary key.</param>
		/// <remarks>
		/// The child nodes that will be updated must have attribute fields that correspond to
		/// the DataTable.  The "keyField" will be used to identify the attribute that serves as 
		/// an identifier of the rows.  The datatable can have less fields than the nodes so
		/// you have the chance to update smaller subsets.
		/// Make sure that you did not call "AcceptChanges" before passing the datatable or this
		/// function will not find any change.
		/// </remarks>
		public static void UpdateChildNodesWithDataTable(XmlNode parentNode, DataTable table, string keyField)
		{
			if (parentNode == null)
			{
				throw new ArgumentNullException("Unable to update child nodes because parentNode is null");
			}
			if (parentNode.HasChildNodes)
			{
				XmlNode firstNode = parentNode.ChildNodes[0];
				//
				// Verify that the fields of first child node match the fields in the data table
				// note that it's ok if the datatable has fewer fields than the nodes.
				string missingFields = "";
				StringCollection columnNames = new StringCollection();				
				foreach (DataColumn col in table.Columns)
				{
					if (firstNode.Attributes[col.ColumnName] == null)
					{
						if (missingFields.Length == 0)
							missingFields = col.ColumnName;
						else 
							missingFields += ", " + col.ColumnName;
					}
					else
						columnNames.Add(col.ColumnName);
				}
				
				if (missingFields.Length > 0)
				{
					throw new  Exception("Unable to update nodes with datatable because the nodes are missing the fields: "+missingFields);
				}

				///
				/// Remove nodes that got deleted from datatable
				///
				DataTable currTable = table.GetChanges(DataRowState.Deleted);
				if (currTable != null)
				{
					//since there is no way to tell which rows got deleted then just remove all nodes 
					//that are not present in the datatable.

					XmlNode nodeToDelete;
					Trace.WriteLine("Rows Deleted:");
					foreach (DataRow row in table.Rows)
					{
						string keyValue = row[keyField].ToString();
						nodeToDelete = SelectNode(parentNode, keyField, keyValue);
						Trace.WriteLine(keyValue);
						if (nodeToDelete != null)
						{
							parentNode.RemoveChild(nodeToDelete);
						}
					}
				}

				///
				/// Update nodes with changes made on the datatable
				///
				currTable = table.GetChanges(DataRowState.Modified);
				if (currTable != null)
				{
					XmlNode nodeToUpdate;
					Trace.WriteLine("Rows Changed:");
					foreach (DataRow row in currTable.Rows)
					{
						string keyValue = row[keyField].ToString();
						Trace.WriteLine(keyValue);
						nodeToUpdate = SelectNode(parentNode, keyField, keyValue);
						if (nodeToUpdate == null) throw new Exception("Unable to update node with '"+keyField+"="+keyValue+"' because it doesn't exist");

						string valueToSet;
						foreach (string colName in columnNames)
						{
							if (colName == keyField) continue;
							valueToSet = row[colName].ToString();
							SetAttributeValue(nodeToUpdate, colName, valueToSet);
						}
					}
				}

				///
				/// Add new nodes to match new rows added to datatable
				/// 
				currTable = table.GetChanges(DataRowState.Added);
				if (currTable != null)
				{
					XmlNode newNode;
					string keyValue;
					XmlDocument doc = parentNode.OwnerDocument; 
					Trace.WriteLine("Rows Added:");
					foreach (DataRow row in currTable.Rows)
					{
						keyValue = row[keyField].ToString();
						Trace.WriteLine(keyValue);
						if (SelectNode(parentNode, keyField, keyValue) == null)
						{
							newNode = doc.CreateElement(firstNode.Name);
							CopyAttributes(row, newNode);
							parentNode.AppendChild(newNode);
						}
						else
						{
							System.Windows.Forms.MessageBox.Show("Can not add duplicate nodes. Row with '"+keyField+"="+keyValue+" was not added.", "Error Updating Nodes from Table");
						}
					}
				}
				table.AcceptChanges();				
			}
				
		}
示例#30
0
		private void DeleteMatchingDescendants(XmlNode xnLayout, FieldDescription fd)
		{
			List<XmlNode> rgxn = new List<XmlNode>();

			foreach (XmlNode xn in xnLayout.ChildNodes)
			{
				string sRef = XmlUtils.GetOptionalAttributeValue(xn, "ref");
				if (sRef == "$child")
				{
					string sLabel = XmlUtils.GetOptionalAttributeValue(xn, "label");
					if (sLabel == fd.Userlabel)
						rgxn.Add(xn);
					else
						DeleteMatchingDescendants(xn, fd);		// recurse!
				}
				else if (sRef == "Custom")
				{
					string sParam = XmlUtils.GetOptionalAttributeValue(xn, "param");
					if (sParam == fd.Name)
						rgxn.Add(xn);
				}
			}

			foreach (XmlNode xn in rgxn)
				xnLayout.RemoveChild(xn);
		}
	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);
		}
	}
示例#32
0
		override public void LoadXML(XmlNode cXmlNode)
		{
			if (null == cXmlNode)
				return;
			base.LoadXML(cXmlNode);
			foreach (XmlAttribute cAttr in cXmlNode.Attributes)
				switch (cAttr.Name)
				{
					case "in_dissolve":
						try
						{															
							nInDissolve = cAttr.Value.Trim().ToByte();
						}
						catch
						{
							throw new Exception("указана некорректная длительность эффекта [" + cAttr.Name + "=" + cAttr.Value + "][TPL:" + cXmlNode.BaseURI + "]"); //TODO LANG
						}
						break;
					case "out_dissolve":
						try
						{
							nOutDissolve = cAttr.Value.Trim().ToByte();
						}
						catch
						{
							throw new Exception("указана некорректная длительность эффекта [" + cAttr.Name + "=" + cAttr.Value + "][TPL:" + cXmlNode.BaseURI + "]"); //TODO LANG
						}
						break;
				}
			XmlNode cChildNode = cXmlNode.SelectSingleNode("value");
			if (null != cChildNode)
			{
				if (null == cChildNode.FirstChild || null == cChildNode.FirstChild.Value || 1 > cChildNode.FirstChild.Value.Length)
					sText = " ";
				else
					sText = cChildNode.FirstChild.Value.FromXML();
					
				cXmlNode.RemoveChild(cChildNode);
			}
			cChildNode = cXmlNode.SelectSingleNode("font");
			if (null != cChildNode)
			{
				cFont.cTemplate = cTemplate;
				cFont.LoadXML(cChildNode);
				cXmlNode.RemoveChild(cChildNode);
			}
		}
示例#33
0
 private XmlNodeList setXmlParams(XmlNode oNode, string sParam, string[] sVals)
 {
     //check it param exisits
     XmlNode oParam=getXmlNode(oNode, sParam);
     if (oParam != null) {
         //check if it has children
         XmlNodeList oKids=getXmlNodeList(oParam, sParam + LISTPOSTFIX);
         foreach (XmlNode oKid in oKids) {
             //remove param
             oParam.RemoveChild(oKid);
         }
         //remove param
         oNode.RemoveChild(oParam);
     }
     //set param
     return createXmlNodeList(oNode, sParam, sVals);
 }
示例#34
0
        private void AddNode(XmlNode node, XmlNode root)
        {
            string[] keyAttrs;
            GetElementKey keyMain = GetKeyMain(node, out keyAttrs);
            string[] keyVals = keyMain.KeyVals;
            string elementName = keyMain.ElementName;

            XmlNode extantNode = null;
            // Value may be null in the Dictionary, even if key is present.
            m_getElementTable.TryGetValue(keyMain, out extantNode);

            // Is the current node a derived node?
            string baseName = XmlUtils.GetOptionalAttributeValue(node, "base");
            if (baseName != null)
            {
                string id = XmlUtils.GetManditoryAttributeValue(node, keyAttrs[keyAttrs.Length - 1]);
                if (id == baseName)
                {
                    // it is an override.
                    if (extantNode == null)
                    {
                        // Possibly trying to override a derived element?
                        extantNode = GetElement(elementName, keyVals);
                        if (extantNode == null)
                            throw new Exception("no base found to override " + baseName);
                    }
                    GetElementKey keyBase = new GetElementKey(elementName, keyVals, m_baseDoc);
                    if (m_getElementTable.ContainsKey(keyBase))
                        throw new Exception("only one level of override is allowed " + baseName);
                    // Save the base node for future use.
                    m_baseDoc["Main"].AppendChild(m_baseDoc.ImportNode(extantNode, true));
                    m_getElementTable[keyBase] = extantNode;
                    // Immediately compute the effect of the override and save it, replacing the base.
                    XmlNode unified = Unify(node, extantNode);
                    root.ReplaceChild(unified, extantNode);
                    // and update the cache, which is loaded with the old element
                    m_getElementTable[keyMain] = unified;
                }
                else
                {
                    // it is a normal alteration node
                    if (extantNode != null)
                    {
                        // derived node displaces non-derived one.
                        root.RemoveChild(extantNode);
                    }
                }
                // alteration node goes into alterations doc (displacing any previous alteration
                // with the same key).
                GetElementKey keyAlterations = new GetElementKey(elementName, keyVals, m_alterationsDoc);
                extantNode = null;
                if (m_getElementTable.ContainsKey(keyAlterations))
                    extantNode = m_getElementTable[keyAlterations]; // May still be null.
                CopyNodeToDoc(node, extantNode, m_alterationsDoc, keyAlterations);
            }
            else // not an override, just save it, replacing existing node if needed
            {
                CopyNodeToDoc(node, extantNode, m_mainDoc, keyMain);
            }
        }
示例#35
0
 //set
 private XmlNode setXmlParam(XmlNode oNode, string sParam, string sVal)
 {
     //check it param exisits
     XmlNode oParam=getXmlNode(oNode, sParam);
     if (oParam != null) {
         //remove param
         oNode.RemoveChild(oParam);
     }
     //set param
     return createXmlNode(oNode, sParam, sVal);
 }
示例#36
0
文件: Program.cs 项目: mil-oss/fgsms
        private bool RemoveASPNetExtensionIfNotExist(XmlNode systemweb, XmlNode webServices, XmlNode soapExtensionTypes, XmlDocument doc)
        {
            if (systemweb == null)
                return false;
            if (webServices == null)
            {
                return false;
            }
            if (soapExtensionTypes == null)
            {
                return false;
            }

            IEnumerator it = soapExtensionTypes.ChildNodes.GetEnumerator();
            while (it.MoveNext())
            {
                XmlNode temp = (XmlNode)it.Current;
                if (temp != null)
                {
                    if (temp.Name == "add")
                    {
                        XmlAttribute a = temp.Attributes["type"];
                        if (a != null)
                        {
                            if (a.Value == ASPNET)
                            {
                                soapExtensionTypes.RemoveChild(temp);
                                return true;
                            }
                        }
                    }

                }
            }

            return false;
        }
示例#37
0
 private static void RemoveAllNodes(XmlDocument doc, XmlNode targetsNode, string xpath)
 {
     var matchingNodes = doc.SelectNodes(xpath);
     foreach (XmlNode node in matchingNodes)
         targetsNode.RemoveChild(node);
 }
示例#38
0
		/// <summary>
		/// Removes nodes with style "display: none;" from HTML document.
		/// </summary>
		private static void RemoveHiddenElements(XmlNode doc)
		{
			var htmlNodesToDelete = doc.SelectNodes("//*[contains(translate(@style,\" \",\"\"),\"display:none\")]");
			if (htmlNodesToDelete != null)
				foreach (XmlNode htmlNode in htmlNodesToDelete)
				{
					htmlNode.RemoveAll();
					if (htmlNode.ParentNode != null)
						htmlNode.ParentNode.RemoveChild(htmlNode);
					else
						doc.RemoveChild(htmlNode);
				}
		}
示例#39
0
 /**
 * 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;
 }
 private static void ClearAllCustomRuntimeSettingsExceptRedirects(XmlNode runtimeElement)
 {
     foreach (XmlNode runtimeSetting in runtimeElement.ChildNodes)
     {
         if (runtimeSetting.Name != "assemblyBinding")
         {
             runtimeElement.RemoveChild(runtimeSetting);
         }
     }
 }
示例#41
-1
 private void RemoveEmptyChildNodes(XmlNode xmlNode)
 {
     var childs = xmlNode.ChildNodes;
     for (int i = 0; i < childs.Count; i++)
     {
         if (childs[i].InnerText == "")
         {
             xmlNode.RemoveChild(childs[i]);
         }
         else
         {
             RemoveEmptyChildNodes(childs[i]);
         }
     }
 }