private void InterpretStyles(HtmlNode htmlNode) { string style; if (!HtmlStyle.IsNonStyleElement(htmlNode.Tag)) { if (htmlNode.Attributes.TryGetValue("style", out style)) { CSSParser cssParser = new CSSParser(); htmlNode.AddStyles(cssParser.ParseRules(style, SelectorType.Inline)); } Parse(htmlNode); } foreach (HtmlNode node in htmlNode.GetChildren()) { InterpretStyles(node); } //This loop only needs when the parent is null. If parent is not null, it will loop through all the //child elements thus next nodes processed without this loop. if (htmlNode.Parent == null && htmlNode.Next != null) { InterpretStyles(htmlNode.GetNext()); } }