Would anyone have any idea as to why this code is throwing a NullReferenceException? Basically what it does is when I click a Search button it executes this method which grabs some stuff from an API and puts into a Object and those Objects into a List.
private List<Show> _shows;
public List<Show> Shows
{
get
{
return _shows;
}
set
{
_shows = value;
}
}
public void Search(string query)
{
List<Show> lijst = new List<Show>();
XmlDocument doc = new XmlDocument();
doc.Load(baseUrl + "/api/GetSeries.php?seriesname=" + query);
XmlNodeList elemList = doc.GetElementsByTagName("Series");
for(int i=0; i < elemList.Count; i++)
{
XmlNode elem = elemList[i];
Uri banner = new Uri("http://ift.tt/1fx5B65" + elem["banner"].InnerText);
Show sh = new Show()
{
Name = elem["SeriesName"].InnerText,
Banner = banner,
Overview = elem["Overview"].InnerText,
FirstAired = Convert.ToDateTime(elem["FirstAired"].InnerText),
};
lijst.Add(sh);
}
this._shows = lijst;
}
I'm quite the beginner when it comes to this stuff so I might be overlooking something really obvious. Thanks in advance anyways.
No comments:
Post a Comment