Exemplo n.º 1
0
        public static void RemoveInlineCssItem(this HtmlNode node, string name)
        {
            if (HasInlineCssWithName(node, name))
            {
                var p = new InlineCssParser(ReadAttributeValue(node, @"style"));
                p.RemoveItem(name);

                var b = node.Attributes.First(
                    a => string.Equals(a.Name, @"style", StringComparison.InvariantCultureIgnoreCase));
                b.Value = p.InlineCss;
            }
        }
Exemplo n.º 2
0
        public static void SetInlineCss(this HtmlNode node, string cssPropertyName, string cssPropertyValue)
        {
            var doc = node.OwnerDocument;

            var b =
                node.Attributes.FirstOrDefault(
                    a => string.Equals(a.Name, @"style", StringComparison.InvariantCultureIgnoreCase));

            if (b == null)
            {
                b = doc.CreateAttribute(@"style");
                node.Attributes.Add(b);
            }

            var p = new InlineCssParser(b.Value);

            p.SetValue(cssPropertyName, cssPropertyValue);

            b.Value = p.InlineCss;
        }
Exemplo n.º 3
0
        public static string ReadInlineCssValue(this HtmlNode node, string name)
        {
            var p = new InlineCssParser(ReadAttributeValue(node, @"style"));

            return(p.GetValue(name));
        }
Exemplo n.º 4
0
        public static bool HasInlineCssWithName(this HtmlNode node, string name)
        {
            var p = new InlineCssParser(ReadAttributeValue(node, @"style"));

            return(p.HasName(name));
        }