/// <summary> /// Apply CSS style to HTML node. /// </summary> private static void MergeStyles(XmlDocument doc, XmlNode htmlNode) { CssStyleProperties style; if (htmlNode.Attributes == null) { return; } if (htmlNode.Attributes["style"] != null) { var oldStyleProperties = new CssStyleProperties { Text = htmlNode.Attributes["style"].Value }; var newStyleProperties = new CssStyleProperties { Text = htmlNode.Attributes["new_style"].Value }; style = newStyleProperties + oldStyleProperties; } else { htmlNode.Attributes.Append(doc.CreateAttribute("style")); style = new CssStyleProperties { Text = htmlNode.Attributes["new_style"].Value }; } if (htmlNode.Attributes["class"] != null) { htmlNode.Attributes.Remove(htmlNode.Attributes["class"]); } htmlNode.Attributes.Remove(htmlNode.Attributes["new_style"]); htmlNode.Attributes["style"].Value = style.Text; }
/// <summary> /// Save CSS style into "". /// </summary> private static void AppendNewStyleAttribute(XmlDocument doc, CssStyle selector, XmlNode htmlNode) { CssStyleProperties style; if (htmlNode.Attributes == null) { return; } if (htmlNode.Attributes["new_style"] != null) { var oldStyleProperties = new CssStyleProperties { Text = htmlNode.Attributes["new_style"].Value }; var newStyleProperties = new CssStyleProperties { Dictionary = selector.Properties.Dictionary }; style = oldStyleProperties + newStyleProperties; } else { htmlNode.Attributes.Append(doc.CreateAttribute("new_style")); style = new CssStyleProperties { Dictionary = selector.Properties.Dictionary }; } htmlNode.Attributes["new_style"].Value = style.Text; }
/// <summary> /// Apply CSS style to HTML node. /// </summary> private static void MergeStyles(XmlDocument doc, XmlNode htmlNode) { CssStyleProperties style; if (htmlNode.Attributes == null) return; if (htmlNode.Attributes["style"] != null) { var oldStyleProperties = new CssStyleProperties { Text = htmlNode.Attributes["style"].Value }; var newStyleProperties = new CssStyleProperties { Text = htmlNode.Attributes["new_style"].Value }; style = newStyleProperties + oldStyleProperties; } else { htmlNode.Attributes.Append(doc.CreateAttribute("style")); style = new CssStyleProperties { Text = htmlNode.Attributes["new_style"].Value }; } if (htmlNode.Attributes["class"] != null) htmlNode.Attributes.Remove(htmlNode.Attributes["class"]); htmlNode.Attributes.Remove(htmlNode.Attributes["new_style"]); htmlNode.Attributes["style"].Value = style.Text; }
/// <summary> /// Save CSS style into "". /// </summary> private static void AppendNewStyleAttribute(XmlDocument doc, CssStyle selector, XmlNode htmlNode) { CssStyleProperties style; if (htmlNode.Attributes == null) return; if (htmlNode.Attributes["new_style"] != null) { var oldStyleProperties = new CssStyleProperties { Text = htmlNode.Attributes["new_style"].Value }; var newStyleProperties = new CssStyleProperties { Dictionary = selector.Properties.Dictionary }; style = oldStyleProperties + newStyleProperties; } else { htmlNode.Attributes.Append(doc.CreateAttribute("new_style")); style = new CssStyleProperties { Dictionary = selector.Properties.Dictionary }; } htmlNode.Attributes["new_style"].Value = style.Text; }