Vignesh Kumar

Vignesh Kumar

  • 1.1k
  • 1k
  • 309.2k

XML element not displaying for empty values

Nov 16 2015 11:57 PM


I am using an xml file to import into the database using the below code.

XmlDocument xmlDoc = new XmlDocument(); 
xmlDoc.Load(path + "Data.xml"); 
XmlNodeList nodeList = xmlDoc.DocumentElement.SelectNodes("/DocumentElement/Profile"); 
//read XML data and ID is one of the column
object[] ID = XDocument.Load(path + "Data.xml").Descendants("ID").Select(element => Element.Value).ToArray();

Now the ID element has null values and when I read them the rows with null values are omitted. How can I set empty string values for those null nodes?

Brought to you by:

Answers (4)