How can i get xml node value from string



I am trying to get XML values from the following XML string ' LLOY.L 76.27 8/29/2014 '


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. any help greatly appreciated


No comments:

Post a Comment