【发布时间】:2015-11-16 12:56:39
【问题描述】:
我正在使用 xml 文件通过以下代码导入数据库
CS:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(pathPMO + "Data.xml");
XmlNodeList nodeList = xmlDoc.DocumentElement.SelectNodes("/DocumentElement/Profile");
bool insertProfile = false;
foreach (XmlNode node in nodeList)
{
strYear = node.SelectSingleNode("Profile_x0020_Year").InnerText;
strID = node.SelectSingleNode("Profile_x0020_ID").InnerText;
strLead = node.SelectSingleNode("Profile_x0020_Leader").InnerText;
insertProfile = ImportProfile(strYear, strID, strLead);
}
例如,某些行的配置文件领导者值为空,当我尝试插入它们时,我收到错误object not set to an instance of an object,因为该特定元素在几行中丢失。
谁能建议如何解决这个问题?
【问题讨论】: