XML file node named as value given error




var nlfaci = xdcDocument.SelectNodes("/ns:HotelDetailRS/ns:Hotel/ns:FacilityList/ns:Feature", nsmgr);

foreach (XmlNode xndNodefac in nlfaci)
{
Label lblfac = new Label();
lblfac.Text = "Code : " + xndNodefac["Code"].InnerText + "<br />";
DivFacilityList.Controls.Add(lblfac);

Label lblfac1 = new Label();
lblfac1.Text = "Name : " + xndNodefac["Name"].InnerText + "<br />";
DivFacilityList.Controls.Add(lblfac1);

Label lblfac2 = new Label();
lblfac2.Text = "Description : " + xndNodefac["Description"].InnerText + "<br /><br />";
DivFacilityList.Controls.Add(lblfac2);

Label lblfac31 = new Label();
lblfac31.Text = "Value : " + xndNodefac["Value"].InnerText + "<br /><br />";
DivFacilityList.Controls.Add(lblfac31);
}


In above code every thing work fine. My cording running very well. But I am getting a issue in Last line " xndNodefac["Value"].InnerText " which given me error "Object reference not set to an instance of an object". In XML File there is a node call "Value" all the nodes are working fine and when it is come to this "Value" node I am getting error.


No comments:

Post a Comment