I am trying to make list of object as
List<FeedItem> List_feeds = new List<FeedItem>();
FeedItem objFeedItem = new FeedItem();
objFeedItem.feedId = feedNode.SelectSingleNode("id").InnerText;
.
.
.
.
objFeedItem.text = feedNode.SelectSingleNode("text").InnerXml;
objFeedItem.imgthumb = thumbImage;
objFeedItem.imglarge = largeImage;
List_feeds.Add(objFeedItem);
Error: "Object reference not set to an instance of an object."
Some One asked for the compleate Code hear it is..
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;
using System.Net;
namespace FSB.Classes
{
public class FeedItem
{
public string feedId{ get; set; }
public string feed_publishDate{ get; set; }
public string feed_createDate{ get; set; }
public string feed_modifieddate{ get; set; }
public string title{ get; set; }
public string description{ get; set; }
public string text{ get; set; }
public string imgthumb{ get; set; }
public string imglarge{ get; set; }
public string addedBy{ get; set; }
public string edited{ get; set; }
public string createDate{ get; set; }
public string updateDat { get; set; }
}
public class Feeds
{
protected string newsURL;
protected List<FeedItem> List_feeds;
public Feeds()
{
newsURL = @"http://api.brafton.com/55f3e621-2223-48de-bafc-4f3774e72533/news/";
List<FeedItem> List_feeds = new List<FeedItem>();
}
public void updateAllFeeds()
{
getFeedList();
}
private void getFeedList()
{
try
{
XmlDocument objFeedDoc = new XmlDocument();
var nodeFeedList = getFeedNodes();
foreach (XmlNode objFeedNode in nodeFeedList)
{
string feedDetailhref = objFeedNode.Attributes["href"].Value;
string strFeedDetail = getFeedDetailXml(feedDetailhref);
objFeedDoc.LoadXml(strFeedDetail);
XmlNode feedNode = objFeedDoc.SelectSingleNode("newsItem");
FeedItem objFeedItem = new FeedItem();
objFeedItem.feedId =feedNode.SelectSingleNode("id").InnerText;
objFeedItem.feedId = feedNode.SelectSingleNode("id").InnerText;
objFeedItem.feed_publishDate = feedNode.SelectSingleNode("publishDate").InnerText;
objFeedItem.feed_createDate = feedNode.SelectSingleNode("createdDate").InnerText;
objFeedItem.feed_modifieddate = feedNode.SelectSingleNode("lastModifiedDate").InnerText;
objFeedItem.title = feedNode.SelectSingleNode("headline").InnerText;
objFeedItem.description = feedNode.SelectSingleNode("htmlMetaDescription").InnerText;
objFeedItem.text = feedNode.SelectSingleNode("text").InnerXml;
string thumbImage = "";
string largeImage = "";
/*
try
{
string pictureURL = feedNode.SelectSingleNode("photos").Attributes["href"].Value;
XmlNode imageNode = getFeedImage(pictureURL);
foreach (XmlNode pic in imageNode)
{
if (pic.SelectSingleNode("type").InnerText.ToLower() == "large")
{
largeImage = pic.SelectSingleNode("url").InnerText;
}
if (pic.SelectSingleNode("type").InnerText.ToLower() == "thumb")
{
thumbImage = pic.SelectSingleNode("url").InnerText;
}
}
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
*/
objFeedItem.imgthumb = thumbImage;
objFeedItem.imglarge = largeImage;
List_feeds.Add(objFeedItem);
}
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
}
private XmlNode getFeedImage(string pictureURL)
{
try
{
XmlDocument picDoc = new XmlDocument();
var client = new WebClient();
var content = client.DownloadString(newsURL);
picDoc.LoadXml(content);
return picDoc.SelectSingleNode("photos/photo/instances");
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
return null;
}
/*Extract the newsListItem from the xml Feeds */
private XmlNodeList getFeedNodes()
{
try
{
XmlDocument docFeed = new XmlDocument();
string strFeedXml = getFeedXml();
docFeed.LoadXml(strFeedXml);
return docFeed.SelectNodes("news/newsListItem");
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
return null;
}
/*Get the Xml Feeds From the Live Server*/
private string getFeedXml()
{
try
{
var client = new WebClient();
var content = client.DownloadString(newsURL);
return content;
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
return null;
}
/*Get the Xml Feeds Details From the Live Server*/
private string getFeedDetailXml(string newsDetailURL)
{
try
{
var client = new WebClient();
var content = client.DownloadString(newsDetailURL);
return content;
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
return null;
}
}
}