private AdferoCategoryList ListCategoriesForArticle(int articleId, int offset, int limit, string[] properties, string[] fields) { string uri = this.GetUri(articleId, "articleId", "xml", properties, fields, offset, limit); uri = string.Format("http://{0}:{1}@{2}", this.credentials.PublicKey, this.credentials.SecretKey, uri.Replace("http://", string.Empty)); string xml = AdferoHelpers.GetXmlFromUri(uri); AdferoCategoryList categories = this.ListCategoriesFromXmlString(xml); categories.Limit = limit; categories.Offset = offset; return(categories); }
private AdferoCategoryList ListCategoriesFromXmlString(string xml) { XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); int totalCount = int.Parse(doc.SelectSingleNode("//categories").Attributes["totalCount"].Value); AdferoCategoryList categoryItems = new AdferoCategoryList(); categoryItems.TotalCount = totalCount; foreach (XmlNode n in doc.SelectNodes("//categories/category")) { foreach (XmlNode na in n.SelectNodes("id")) { AdferoCategoryListItem category = new AdferoCategoryListItem(); category.Id = int.Parse(na.InnerText); categoryItems.Items.Add(category); } } return(categoryItems); }
private AdferoCategoryList ListCategoriesFromXmlString(string xml) { XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); int totalCount = int.Parse(doc.SelectSingleNode("//categories").Attributes["totalCount"].Value); AdferoCategoryList categoryItems = new AdferoCategoryList(); categoryItems.TotalCount = totalCount; foreach (XmlNode n in doc.SelectNodes("//categories/category")) { foreach (XmlNode na in n.SelectNodes("id")) { AdferoCategoryListItem category = new AdferoCategoryListItem(); category.Id = int.Parse(na.InnerText); categoryItems.Items.Add(category); } } return categoryItems; }