private static void ParseEmotion(HtmlElement root) { var list = root.Element("ul"); if (list == null) { return; } foreach (var li in list.Descendants("li")) { HtmlElement a = li.Element("a"); HtmlElement img = null; if (a != null && (img = a.Element("img")) != null) { var onclick = a.Attributes["onclick"]; var id = ""; var match = smilePattern.Match(onclick); if (match.Success) { id = match.Groups["id"].Value; } var path = img.Attributes["src"]; if (id.Length > 0 && path.Length > 0) { EmotionList[id] = new EmotionItemViewModel { Id = id, Path = path } } ; } } } }
private static void ParseEmotionXml(Stream xml) { var root = XDocument.Load(xml).Root; foreach (var item in root.Descendants("img")) { var id = item.Attribute("Id").Value; var path = item.Attribute("Path").Value; EmotionList[id] = new EmotionItemViewModel { Id = id, Path = path }; } }
private static void ParseEmotionXml(Stream xml) { var root = XDocument.Load(xml).Root; foreach (var item in root.Descendants("img")) { var id = item.Attribute("Id").Value; var path = item.Attribute("Path").Value; EmotionList[id] = new EmotionItemViewModel { Id = id, Path = path }; } }
private static void ParseEmotion(HtmlElement root) { var list = root.Element("ul"); if (list == null) return; foreach (var li in list.Descendants("li")) { HtmlElement a = li.Element("a"); HtmlElement img = null; if (a != null && (img = a.Element("img")) != null) { var onclick = a.Attributes["onclick"]; var id = ""; var match = smilePattern.Match(onclick); if (match.Success) id = match.Groups["id"].Value; var path = img.Attributes["src"]; if (id.Length > 0 && path.Length > 0) EmotionList[id] = new EmotionItemViewModel { Id = id, Path = path }; } } }