Esempio n. 1
0
    public void DeleteFromXml(string PageName, int PageId, int UserId)
    {
        try
        {
            int         PId    = PageId;
            int         UId    = UserId;
            XmlDocument xmldoc = new XmlDocument();
            xmldoc.Load(Session["HomePath"].ToString() + BannerOrder.BannerXml);
            XmlNodeList Node1;

            Node1 = xmldoc.GetElementsByTagName("banner");
            int Totalcnt = Node1.Count;
            for (int i = 0; i < Node1.Count; i++)
            {
                XmlElement id = (XmlElement)xmldoc.GetElementsByTagName("banner")[i];

                if (id.ChildNodes.Item(4).InnerText.ToString() == PageName)
                {
                    id.ParentNode.RemoveChild(id);
                    i = i - 1;
                }
            }
            int tempNodeId = 0;
            tempNodeId = GetPagesNode(PId, UId);
            XmlNodeList Node2;
            Node2 = xmldoc.GetElementsByTagName("banners");
            int         c = Node2.Item(tempNodeId).ChildNodes.Count;
            XmlNodeList Node3;
            Node3 = xmldoc.GetElementsByTagName("bannerName");
            Node3.Item(tempNodeId).FirstChild.InnerText = Node2.Item(tempNodeId).ChildNodes.Count.ToString();
            xmldoc.Save(ContentManager.GetPhysicalPath(Session["HomePath"].ToString() + "banners_Cat1.xml"));
        }
        catch (Exception Ex) { ErrMessage(Ex.Message.ToString()); }
    }
Esempio n. 2
0
        public void DeleteFromXml(string str)
        {
            XmlDocument xmldoc = new XmlDocument();

            xmldoc.Load(Session["HomePath"].ToString() + "banners_Cat.xml");
            XmlNodeList Node1;

            Node1 = xmldoc.GetElementsByTagName("banner");

            for (int i = 0; i < Node1.Count; i++)
            {
                XmlElement id = (XmlElement)xmldoc.GetElementsByTagName("banner")[i];

                if (id.ChildNodes.Item(2).InnerText.ToString() == str)
                {
                    id.ParentNode.RemoveChild(id);
                }
            }
            XmlNodeList Node2;

            Node2 = xmldoc.GetElementsByTagName("banners");
            int         c = Node2.Item(Convert.ToInt32(ddlUserType.SelectedValue)).ChildNodes.Count;
            XmlNodeList Node3;

            Node3 = xmldoc.GetElementsByTagName("bannerName");
            Node3.Item(Convert.ToInt32(ddlUserType.SelectedValue)).FirstChild.InnerText = Node2.Item(Convert.ToInt32(ddlUserType.SelectedValue)).ChildNodes.Count.ToString();
            xmldoc.Save(ContentManager.GetPhysicalPath(Session["HomePath"].ToString() + "banners_Cat.xml"));
        }