Bloom.Book.HtmlDom.UpdateMetaElement C# (CSharp) Method

UpdateMetaElement() public method

creates if necessary, then updates the named in the head of the html
public UpdateMetaElement ( string name, string value ) : void
name string
value string
return void
        public void UpdateMetaElement(string name, string value)
        {
            XmlElement n = _dom.SelectSingleNode("//meta[@name='" + name + "']") as XmlElement;
            if(n == null)
            {
                n = _dom.CreateElement("meta");
                n.SetAttribute("name", name);
                _dom.SelectSingleNode("//head").AppendChild(n);
            }
            n.SetAttribute("content", value);
        }

Usage Example

        public void Save()
        {
            Logger.WriteEvent("BookStorage.Saving... (eventual destination: {0})", PathToExistingHtml);

            Dom.UpdateMetaElement("Generator", "Bloom " + ErrorReport.GetVersionForErrorReporting());
            if (null != Assembly.GetEntryAssembly())             // null during unit tests
            {
                var ver = Assembly.GetEntryAssembly().GetName().Version;
                Dom.UpdateMetaElement("BloomFormatVersion", kBloomFormatVersion);
            }
            MetaData.FormatVersion = kBloomFormatVersion;
            string tempPath = SaveHtml(Dom);


            string errors = ValidateBook(tempPath);

            if (!string.IsNullOrEmpty(errors))
            {
                Logger.WriteEvent("Errors saving book {0}: {1}", PathToExistingHtml, errors);
                var badFilePath = PathToExistingHtml + ".bad";
                File.Copy(tempPath, badFilePath, true);
                //hack so we can package this for palaso reporting
                errors += string.Format("{0}{0}{0}Contents:{0}{0}{1}", Environment.NewLine,
                                        File.ReadAllText(badFilePath));
                var ex = new XmlSyntaxException(errors);

                Palaso.Reporting.ErrorReport.NotifyUserOfProblem(ex, "Before saving, Bloom did an integrity check of your book, and found something wrong. This doesn't mean your work is lost, but it does mean that there is a bug in the system or templates somewhere, and the developers need to find and fix the problem (and your book).  Please click the 'Details' button and send this report to the developers.  Bloom has saved the bad version of this book as " + badFilePath + ".  Bloom will now exit, and your book will probably not have this recent damage.  If you are willing, please try to do the same steps again, so that you can report exactly how to make it happen.");
                Process.GetCurrentProcess().Kill();
            }
            else
            {
                Logger.WriteMinorEvent("ReplaceFileWithUserInteractionIfNeeded({0},{1})", tempPath, PathToExistingHtml);
                if (!string.IsNullOrEmpty(tempPath))
                {
                    FileUtils.ReplaceFileWithUserInteractionIfNeeded(tempPath, PathToExistingHtml, null);
                }
            }

            MetaData.Save();
        }
All Usage Examples Of Bloom.Book.HtmlDom::UpdateMetaElement