private void ParseImage(XElement imageNode) { OnContentItemLoadingStart(); RealmsContentProvider.ImageData data = new RealmsContentProvider.ImageData(); foreach (var node in imageNode.Descendants()) { switch (node.Name.ToString()) { case "a": data.title = node.Attribute("title").Value; break; case "img": data.url = node.Attribute("src").Value; break; default: break; } } data.description = string.Empty; gallery.images.Add(data); OnContentItemLoadingComplete(); }
private void LoadImage(RealmsContentProvider.ImageData data) { _title.text = data.title; _description.text = data.description; _display.enabled = false; RealmsResourceManager.LoadImage(data.url, OnImageLoaded); }
private void ParseBlogPost(XElement blogPostNode) { // Debug.Log ("parse blog"); RealmsContentProvider.ImageData data = new RealmsContentProvider.ImageData(); data.url = blogPostNode .Descendants() .Where(node => node.Attribute("class") != null) .Where(node => node.Attribute("class").Value == "et_post_meta_wrapper") .Descendants() .Where(subNode => subNode.Name == "img") .ElementAt(0) .Attribute("src") .Value; data.title = blogPostNode .Descendants() .Where(node => node.Attribute("class") != null) .Where(node => node.Attribute("class").Value == "entry-title") .ElementAt(0) .Value; data.description = blogPostNode .Descendants() .Where(node => node.Attribute("class") != null) .Where(node => node.Attribute("class").Value == "entry-content") .ElementAt(0) .Value .Replace("<p>", string.Empty) .Replace("</p>", string.Empty); gallery.images.Insert(0, data); OnContentItemLoadingComplete(); }
private void ParseItem(XElement item) { RealmsContentProvider.ImageData data = new RealmsContentProvider.ImageData(); data.title = item .Descendants() .Where(node => node.Name == "title") .First() .Value ; XElement content = item .Descendants() .Where(node => node.Name.ToString().Contains("content")) .First(); string srtString = "src=\""; int srcIndexFrom = content.Value.IndexOf(srtString) + srtString.Length; int srcIndexTo = content.Value.IndexOf("\" ", srcIndexFrom); data.url = content.Value.Substring(srcIndexFrom, srcIndexTo - srcIndexFrom); int descriptionIndexFrom = content.Value.IndexOf("/>", srcIndexTo); string descriptionText = content .Value .Substring(descriptionIndexFrom + 2) .Replace("<p>", string.Empty) .Replace("</p>", string.Empty) .Replace("<em>", string.Empty) .Replace("</em>", string.Empty) ; data.description = RealmsDataUtils.ReplaceASCIICodesWithUTF(descriptionText); gallery.images.Add(data); }