private string SafeGetAttributeValue(HtmlNodeCollection collection, string name) { string result = string.Empty; var attr = collection .Select(n => n.Attributes.FirstOrDefault(a => a.Name == name)) .FirstOrDefault(); if (attr != null) { result = attr.Value; } return result; }
public List<string> GetAllImageSrcs(string str) { HtmlDocument doc = new HtmlDocument(); doc.Load(str.ToStream()); HtmlNodeCollection imgs = new HtmlNodeCollection(doc.DocumentNode.ParentNode); imgs = doc.DocumentNode.SelectNodes("//img"); if (imgs == null || !imgs.Any()) { return null; } var result = imgs.Select(i => @"https://rally1.rallydev.com"+i.Attributes[@"src"].Value).ToList(); return result; }
public FsdContentItemCells(HtmlNodeCollection nodes) { _innerHtml = string.Join(string.Empty, nodes.Select(node => node.OuterHtml)); _cells = nodes.Select((c, i) => new { key = (FsdContentItemProperty)i, value = c.InnerText.Trim() }).ToDictionary(k => k.key, k => k.value); }