private async Task ParseMediaEntry(string mediaEntryString, PicasaPostImage postImage) { postImage.srcUrl = null; // First try <content src> var xmlDoc = new Windows.Data.Xml.Dom.XmlDocument(); xmlDoc.LoadXml(mediaEntryString); var contentEl = xmlDoc.SelectSingleNodeNS("/atom:entry/atom:content", _nsMgr.ToNSMethodFormat()); if (contentEl != null) { postImage.srcUrl = XmlHelper.GetUrl(contentEl, "@src", _nsMgr, null); } // Then try media RSS if (postImage.srcUrl == null || postImage.srcUrl.Length == 0) { contentEl = xmlDoc.SelectSingleNodeNS("/atom:entry/media:group/media:content[@medium='image']", _nsMgr.ToNSMethodFormat()); if (contentEl == null) { throw new ArgumentException("Picasa photo entry was missing content element"); } postImage.srcUrl = XmlHelper.GetUrl(contentEl, "@url", _nsMgr, null); } postImage.editUri = AtomEntry.GetLink(xmlDoc.SelectSingleNodeNS("/atom:entry", _nsMgr.ToNSMethodFormat()), _nsMgr, "edit-media", null, null, null); }
protected virtual void ParseResponse(XmlDocument xmlDoc, PostNewImageResult result) { XmlElement contentEl = xmlDoc.SelectSingleNodeNS("/atom:entry/atom:content", _nsMgr.ToNSMethodFormat()) as XmlElement; result.srcUrl = XmlHelper.GetUrl(contentEl, "@src", null); result.editUri = AtomEntry.GetLink(xmlDoc.SelectSingleNodeNS("/atom:entry", _nsMgr.ToNSMethodFormat()) as XmlElement, _nsMgr, "edit-media", null, null, null); result.editEntryUri = AtomEntry.GetLink(xmlDoc.SelectSingleNodeNS("/atom:entry", _nsMgr.ToNSMethodFormat()) as XmlElement, _nsMgr, "edit", null, null, null); result.selfPage = AtomEntry.GetLink(xmlDoc.SelectSingleNodeNS("/atom:entry", _nsMgr.ToNSMethodFormat()) as XmlElement, _nsMgr, "alternate", null, null, null); }