Witam wszystkich. Chciałbym wczytać ze strony internetowej nazwy walut i ich wartości. Wykorzystałem w tym celu XmlNodeList i przekazałem w tagu "Cube". Obecnie w pętli mam 33 węzły "Cube" i chciałbym wyświetlić wartość atrybutów currency i rate . Ale mam błąd "System.NullReferenceException:" Odwołanie do obiektu nie zostało ustawione na instancję obiektu ".
private void LoadCurrency()
{
XmlDocument doc = new XmlDocument();
XmlNodeList nodeList;
doc.Load("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml");
nodeList = doc.GetElementsByTagName("Cube");
for(int i=0;i<nodeList.Count;i++)
{
string str = String.Format("Currency={0} Rate={1}",nodeList[i].ChildNodes.Item(1).InnerText, nodeList[i].ChildNodes.Item(2).InnerText);
listBox1.Items.Add(str.ToString());
}
}
Wszelka pomoc lub sugestia są mile widziane.