XML元素不显示空值 [英] XML element not displaying for null values

查看:343
本文介绍了XML元素不显示空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我使用以下代码将xml文件导入数据库。

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();



现在ID元素具有空值,当我读取它们时,省略了具有空值的行。如何为这些空节点设置空字符串值?


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?

推荐答案

查看此问题的答案,答案帖的作者简要回顾了问题: http://stackoverflow.com/questions/774192/what- is-the-correct-way-to-represent-null-xml-elements [ ^ ]。



另请参阅我的评论和其他我提供的链接......



-SA
Look at the answers to this question where the authors of the answer post briefly reviewed the problem: http://stackoverflow.com/questions/774192/what-is-the-correct-way-to-represent-null-xml-elements[^].

See also my comments and another link I provided…

—SA


这篇关于XML元素不显示空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆