Am trying to loop through xmlnodes. but getting this error "Object reference not set to an instance of an object." My main goal was to loop it through the datgridviewcell but i don't know how i can take it further. I know the column indexes for font,date and comment from my grid. how can i loop through those column indexes and be able to parse the value to string?
<?xml version="1.0" encoding="utf-8"?>
<root>
<data name="Button"xml:space="preserve">
<value></value>
<comment>[Font][/Font][DateStamp][/DateStamp[Comment][/Comment]</comment>
</data>
XmlNodeList _Nodelist = _doc.SelectNodes("/root");
foreach(XmlNode _Xnode in _Nodelist)
{
XmlNode _data = _Xnode.SelectSingleNode("data");
XmlNodeList _CommentNodes = _data.SelectNodes("comment");
if(_CommentNodes != null)
{
foreach(XmlNode node in _CommentNodes)
{
XmlNode _comment = node.SelectSingleNode("comment");
{
string _font = _comment["Font"].InnerText; //it throws the error here
string _Date = _comment["DateStamp"].InnerText;
string _Comment = _comment["Comment"].InnerText;
}
}
}
}