static TagMetadata() { NoTag = new TagMetadata() { Title = "No Icon", Value = "0", TagUri = string.Empty }; }
private static TagMetadata ParseValue(this TagMetadata data, HtmlNode parent) { var node = parent.Descendants("div") .Where(n => n.GetAttributeValue("class", "").Equals(SMILEY_TEXT_ATTRIBUTE_VALUE)) .FirstOrDefault(); string value = string.Empty; if (node != null) { value = node.InnerText; } data.Value = value; return(data); }
private static TagMetadata ParseTitleAndUri(this TagMetadata data, HtmlNode parent) { var node = parent.Descendants("img") .FirstOrDefault(); if (node != null) { string uri = node.GetAttributeValue(SMILEY_URI_ATTRIBUTE, ""); string title = node.GetAttributeValue(SMILEY_TITLE_ATTRIBUTE, ""); data.TagUri = uri; data.Title = title; } return(data); }
private static TagMetadata ParseTag(HtmlNode node) { TagMetadata tag = new TagMetadata(); var imgNode = node.Descendants("img").FirstOrDefault(); if (imgNode != null) { tag.TagUri = imgNode.GetAttributeValue("src", ""); } var inputNode = node.Descendants("input").FirstOrDefault(); if (inputNode != null) { tag.Value = inputNode.GetAttributeValue("value", ""); } return(tag); }
public static List <TagMetadata> ParseSmiliesFromNode(HtmlDocument doc) { List <TagMetadata> list = null; try { list = new List <TagMetadata>(); var nodes = doc.DocumentNode.Descendants(SMILEY_NODE_PARENT_ELEMENT) .Where(node => node.GetAttributeValue("class", "").Equals(SMILEY_NODE_ATTRIBUTE_VALUE)); foreach (var node in nodes) { TagMetadata data = new TagMetadata() .ParseValue(node) .ParseTitleAndUri(node); list.Add(data); } } catch (Exception) { } return(list); }