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

SelectChildImgAndBackgroundImageElements() public static method

public static SelectChildImgAndBackgroundImageElements ( XmlElement element ) : XmlNodeList
element System.Xml.XmlElement
return System.Xml.XmlNodeList
        public static XmlNodeList SelectChildImgAndBackgroundImageElements(XmlElement element)
        {
            return element.SelectNodes(".//img | .//*[contains(@style,'background-image')]");
        }

Usage Example

Example #1
0
        /// <summary>
        /// We mirror several metadata tags in the html for quick access by the UI.
        /// This method makes sure they are all up to date.
        /// </summary>
        /// <param name="progress"> </param>
        public static void UpdateAllHtmlDataAttributesForAllImgElements(string folderPath, HtmlDom dom, IProgress progress)
        {
            //Update the html attributes which echo some of it, and is used by javascript to overlay displays related to
            //whether the info is there or missing or whatever.

            var imgElements = HtmlDom.SelectChildImgAndBackgroundImageElements(dom.RawDom.DocumentElement);
            int completed   = 0;

            foreach (XmlElement img in imgElements)
            {
                progress.ProgressIndicator.PercentCompleted = (int)(100.0 * (float)completed / (float)imgElements.Count);
                UpdateImgMetdataAttributesToMatchImage(folderPath, img, progress);
                completed++;
            }
        }