I am trying to get XML values from the following XML node:
<StockQuotes>
<Stock>
<Symbol>LLOY.L</Symbol>
<Last>76.27</Last>
<Date>8/29/2014</Date>
</Stock>
</StockQuotes>
Here is my code:
XmlDocument quoteXML = new XmlDocument();
string strData = myXMLfile;
quoteXML.LoadXml(strData);
XmlNode nodes = quoteXML.SelectSingleNode("StockQuotes/Stock/Last/Date");
string strPrice = nodes["Last"].InnerText;
string strDate = nodes["Date"].InnerText;
Response.Write( strPrice + strDate );
I am getting the error:
Object reference not set to an instance of an object.
when I write the whole string strData
to the view I get all of the XML so I know the file is valid.