有人可以发布示例代码,使用XmlDeserialization将XML文件数据写入SQL数据库吗?
我想只将选定的节点值保存到SQL。
这是一个示例XML节点。我想保存每个子节点值。
<Event>
<ID>ApplicationStart</ID>
<UserID>
</UserID>
<TimeStamp>634577331261524905</TimeStamp>
<LocationID>5</LocationID>
</Event>
这是我的代码:
StreamReader fs = new StreamReader(path);
XmlSerializer serializer = new XmlSerializer(typeof(List<AttendanceLogBo>));
var xmlAttendanceLogBos = serializer.Deserialize(fs) as List<AttendanceLogBo>;
foreach (var res in xmlAttendanceLogBos.c)
Console.WriteLine(res.value.OuterXml);
attendanceLogBos.Add(new AttendanceLogBo()
{
ReaderId = ,
CustomEmployeeId = l,
LogDateTime = DateTime.Now, //DateTime.Parse((item[2]).Substring(0, 6));
EventId = ,
EventLogId = 255,
IsProcessed = false,
LocationId = User.GetCemexUser().LocationId
});
_logImportService.Uploadlog(attendanceLogBos);
我想将所有xml节点值添加到List