private static PagedList <Comment> GetCategories(XmlDocument doc) { PagedList <Comment> comments = new PagedList <Comment>(); XmlNode rootNode = doc.SelectSingleNode("/comments"); comments.PageIndex = Int32.Parse(rootNode.Attributes["pageIndex"].Value); comments.PageSize = Int32.Parse(rootNode.Attributes["pageSize"].Value); comments.TotalRecords = Int32.Parse(rootNode.Attributes["totalComments"].Value); XmlNodeList nodes = doc.SelectNodes("/comments/comment"); foreach (XmlNode node in nodes) { Comment comment = new Comment(); comment.Id = Int32.Parse(node.Attributes["id"].Value); comment.PostId = Int32.Parse(node.Attributes["postId"].Value); comment.Body = node.SelectSingleNode("body").InnerText; comment.SpamScore = Int32.Parse(node.SelectSingleNode("spamScore").InnerText); comment.IsPublished = bool.Parse(node.SelectSingleNode("isPublished").InnerText); comment.IsTrackback = bool.Parse(node.SelectSingleNode("isTrackback").InnerText); comment.IsDeleted = bool.Parse(node.SelectSingleNode("isDeleted").InnerText); comment.Url = node.SelectSingleNode("url").InnerText; XmlNode userName = node.SelectSingleNode("userName"); if (userName != null) { comment.UserName = userName.InnerText; } XmlNode name = node.SelectSingleNode("name"); if (name != null) { comment.Name = name.InnerText; } XmlNode email = node.SelectSingleNode("email"); if (email != null) { comment.Email = email.InnerText; } XmlNode ws = node.SelectSingleNode("webSite"); if (ws != null) { comment.WebSite = ws.InnerText; } XmlNode ip = node.SelectSingleNode("ipAddress"); if (ip != null) { comment.IPAddress = ip.InnerText; } comment.Date = DateTime.Parse(node.SelectSingleNode("published").InnerText); comments.Add(comment); } return(comments); }