XML Reader threw Object Null exception, but node exists(?!)

Tbb

New Member
I am hoping someone could enlighten me as to why I am getting the annoying - "xml object reference not set to an instance .." error.The elements (nodes?) I am looking for seem to exist and I have not misspelled it either :[I might be doing something stupid here, but any help at all would be greatly appreciated.My Code:\[code\] private void button1_Click(object sender, RoutedEventArgs e){ XmlDocument reader = new XmlDocument(); reader.Load("Kotaku - powered by FeedBurner.xml"); XmlNodeList titles = reader.GetElementsByTagName("title"); XmlNodeList dates = reader.GetElementsByTagName("pubDate"); XmlNodeList descriptions = reader.GetElementsByTagName("description"); XmlNodeList links = reader.GetElementsByTagName("link"); for (int i = 0; i < titles.Count; i++) { textBox1.AppendText(Environment.NewLine + titles.InnerText); textBox1.AppendText(Environment.NewLine + descriptions.InnerText); //<<-- Throws Object Ref Null Exception textBox1.AppendText(Environment.NewLine + links.InnerText); textBox1.AppendText(Environment.NewLine + dates.InnerText); //<<-- Throws Object Ref Null Exception } }\[/code\]The XML I am using is a saved XML page from: http://feeds.gawker.com/kotaku/fullThe way I am working on it now is as follows: I have saved the page from the above link (which is an XML page) and put it next to my EXE for easier access.Then I run the code.
 
Back
Top