如何通过C#代码解决Xml元素未被读入的问题? [英] How Do I Resolve The Issue Of Xml Element Not Being Read In By C# Code?

查看:71
本文介绍了如何通过C#代码解决Xml元素未被读入的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由设置元素组成的XML文件。所有其他元素都在DataTable中填充但设置。

在读取XML文件时,这是我实现的参考代码。

但是断点没有达到设置案例。



I have an XML file consisting of an element "Settings". All the rest of the elements are getting populated in DataTable but settings.
While reading in the XML file this is the reference code i implemented.
But the breakpoint is not hitting the "Settings" case.

foreach (DataRow drow in dtFilteredDeviceDefintion.Rows)
               {
                   if (drow["Section"] == null || drow["Section"] == DBNull.Value)
                       continue;

                   string sectionName = Convert.ToString(drow["Section"]).ToLower().Trim();

                   switch (sectionName)
                   {
                       case "devicedefinition":
                           if (drow["DeviceCommunication"] != null && drow["DeviceCommunication"] != DBNull.Value)
                               deviceDefinitionType.DeviceCommunication = Convert.ToInt32(drow["DeviceCommunication"].ToString());

                           if (drow["UserAuthenticationType"] != null && drow["UserAuthenticationType"] != DBNull.Value)
                               deviceDefinitionType.UserAuthentication = Convert.ToInt32(drow["UserAuthenticationType"]);
                           deviceDefinitionType.ID = Convert.ToString(drow["DeviceDefinitionID"]);
                           deviceDefinitionType.SoftwareVersion = Convert.ToString(drow["SoftwareVersion"]);
                           deviceDefinitionType.DeviceType = Convert.ToString(drow["DeviceType"]);
                           deviceDefinitionType.Model = Convert.ToString(drow["Model"]);
                           deviceDefinitionType.Manufacturer = Convert.ToString(drow["Manufacturer"]);
                           break;
                       case "settings":
                           SettingType st = new SettingType();
                           st.Name = Convert.ToString(drow["SettingName"]);
                           st.Description = Convert.ToString(drow["SettingDescription"]);
                           st.IsInitialDeviceSetting = Convert.ToString(drow["IsInitialDeviceSetting"]).ToLower() == "true" ? true : false;
                           st.ReadOnlySpecified = true;
                           st.ReadOnly = Convert.ToString(drow["IsReadOnly"]).ToLower() == "true" ? true : false;
                           st.SettingDisplayText = Convert.ToString(drow["SettingLabel"]);
                           st.ID = Convert.ToString(drow["DeviceDefinitionSettingID"]);
                           st.CategoryID = Convert.ToString(drow["DeviceDefinitionCategoryID"]);

                           if (drow["DisplayOrder"] != null && drow["DisplayOrder"] != DBNull.Value)
                           {
                               st.DisplayOrder = Convert.ToInt32(drow["DisplayOrder"]);
                           }





这些单个元素未被读取的原因是什么?



What can be the reasons that this single element is not being read while others are?

推荐答案

这篇关于如何通过C#代码解决Xml元素未被读入的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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