Example #1
0
        private void RenameInTree(Page page, string name, string pageName)
        {
            name = Common.CleanToSafeString(name);

            XmlNode newTreeNode = _treeDocument.CreateElement(name);
            XmlNode parentNode  = page.TreeNode.ParentNode;

            string newPageidentifier = string.Empty;

            if (parentNode != null)
            {
                newPageidentifier = parentNode.Name;
            }

            // Copy children and attributes
            newTreeNode.InnerXml = page.TreeNode.InnerXml;
            CommonXml.CopyAttributes(page.TreeNode, newTreeNode);
            CommonXml.SetAttributeValue(newTreeNode, "name", name);
            CommonXml.SetAttributeValue(newTreeNode, "pagename", pageName);
            CommonXml.SetAttributeValue(newTreeNode, "pageidentifier", newPageidentifier + "/" + name);

            // Replace old node with new
            if (parentNode != null)
            {
                parentNode.ReplaceChild(newTreeNode, page.TreeNode);
            }
        }