private static void ProcessDocStyles(IHtmlDocument doc) { var parser = new StyleParser(); var style = doc.QuerySelector("STYLE"); parser.Parse(style.TextContent); FixStyle(parser, "TD", "text-align", "right", "left"); FixStyle(parser, "TH", "text-align", "right", "left"); style.TextContent = parser.ToString(); }
private static void FixStyle(StyleParser parser, string selector, string name, string oldVal, string newVal) { var rule = parser .Stylesheet .FirstOrDefault(sel => sel.Name == selector); if (rule != null) { var val = rule.Properties .FirstOrDefault(x => x.Name == name && x.Value == oldVal); if (val != null) { val.Value = newVal; } } }