4
Answers

XML element not displaying for empty values

Vignesh Kumar

Vignesh Kumar

9y
445
1

Hi,

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?

Answers (4)