// Includes XML IO
        public void UpdateElement(Element element)
        {
            if (element == root)
            {
                dbControl.UpdateFragmentElementIntoXML(element);
                return;
            }

            if (element.IsCommandNote)
            {
                return;
            }

            if (element.ParentElement == null)
            {
                return;
            }

            if (element.IsLocalHeading)
            {
                string previousName = System.IO.Directory.GetParent(element.Path).Name;
                string currentName = HeadingNameConverter.ConvertFromHeadingNameToFolderName(element);
                if (previousName != currentName)
                {
                    if (CheckOpenFiles(element) == true)
                    {
                        return;
                    }
                }
            }

            if (element.ParentElement.Path != root.Path)
            {
                DatabaseControl temp_dbControl = new DatabaseControl(element.ParentElement.Path);
                temp_dbControl.newXooMLCreate += new NewXooMLCreateDelegate(dbControl_newXooMLCreate);
                temp_dbControl.OpenConnection();
                temp_dbControl.elementStatusChangedDelegate += new ElementStatusChangedDelegate(dbControl_elementStatusChanged);
                temp_dbControl.UpdateElementIntoXML(element);
                temp_dbControl.CloseConnection();
            }
            else
            {
                dbControl.UpdateElementIntoXML(element);
            }

            switch (element.Type)
            {
                case ElementType.Heading:
                    if (element.IsLocalHeading)
                    {
                        string previousPath = element.Path;
                        element.Path = element.ParentElement.Path + HeadingNameConverter.ConvertFromHeadingNameToFolderName(element) + System.IO.Path.DirectorySeparatorChar;
                        try
                        {
                            RenameFolder(element, previousPath);
                        }
                        catch (Exception)
                        {
                            element.Path = previousPath;
                            element.NoteText = System.IO.Directory.GetParent(element.Path).Name;
                            MessageBox.Show("The heading name is too long, please shorten the name and try again.");
                            return;
                        }
                    }
                    DatabaseControl temp_dbControl = new DatabaseControl(element.Path);
                    temp_dbControl.newXooMLCreate +=new NewXooMLCreateDelegate(dbControl_newXooMLCreate);
                    temp_dbControl.OpenConnection();
                    temp_dbControl.UpdateFragmentElementIntoXML(element);
                    temp_dbControl.CloseConnection();
                    break;
                case ElementType.Note:
                    break;
            };
        }