将节点包含"level ="的XML文件读取到DataSet对象中. [英] Reading XML file with nodes containing 'level=' into a DataSet object.

查看:74
本文介绍了将节点包含"level ="的XML文件读取到DataSet对象中.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个XML文件,该文件将读取到DataSet对象中以导入到SQL Server.我注意到某些节点包含属性"level =".我想知道在尝试加载DataSet对象时如何在程序中处理此问题. 我想它可能会创建多个字段,或者可能将数据连接到同一字段中,这实际上对于该项目而言是更理想的.我正在寻找关于节点< Department>的此'level ='到底要做什么的一些见解.如何 在这方面,将是使用DataSet导入到SQL Server的最佳方法?

I have an XML file that I will be reading into a DataSet object for import to SQL Server. I am noticing that some of the nodes contain an attribute 'level='. I am wondering how this will be handled within my program when I try to load the DataSet object. I suppose it may create multiple fields or perhaps concatenate the data into the same field which would actually be more desirable for this project. I'm looking for some insight on what exactly to do with this 'level=' for the node <Department>. How would be the best way to import to SQL Server with DataSet in this regard?

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Personnel>
	<Person name="Vincent McMahon">
		<Personal>
			<Gender>M</Gender>
			<DOB>1945-10-04</DOB>
			<Address></Address>
			<City></City>
			<State></State>
			<Zip5>06902</Zip5>
			<Phone></Phone>
		</Personal>
		<Internal>
			<ID>321679814</ID>
			<StartDate>1971-01-01</StartDate>
			<Active>Y</Active>
			<Department level="1">Engineering</Department>
			<Department level="2">Quality Assurance</Department>
			<Title>Quality Assurance Manager</Title>
			<Manager>Selig</Manager>
		</Internal>
	</Person>
	<Person name="Patricia Stratigias">
		<Personal>
			<Gender>F</Gender>
			<DOB>DOB>
			<Address></Address>
			<City></City>
			<State>ON</State>
			<ZipC></ZipC>
		</Personal>
		<Internal>
			<ID>654981354</ID>
			<StartDate>2000-04-14</StartDate>
			<Active>Y</Active>
			<Department level="1">Engineering</Department>
			<Department level="2">Quality Assurance</Department>
			<Title>Senior Quality Assurance Engineer</Title>
			<Manager>Francona</Manager>
		</Internal>
	</Person>
	<Person name="Ted DiBeasi">
		<Personal>
			<Gender>M</Gender>
			<DOB></DOB>
			<Address></Address>
			<City></City>
			<State>MS</State>
			<Zip5></Zip5>
			<Zip4></Zip4>
			<Phone></Phone>
		</Personal>
		<Internal>
			<ID>981433305</ID>
			<StartDate>1975-06-01</StartDate>
			<Active>N</Active>
			<EndDate>2002-08-22</EndDate>
			<Department level="1">Engineering</Department>
			<Department level="2">Quality Assurance</Department>
			<Title>Quality Assurance Engineer</Title>
			<Manager>Francona</Manager>
		</Internal>
	</Person>
</Personnel>


谢谢!


Thank You!

推荐答案

好吧,就像在C#论坛中一样:我们无法告诉你.这取决于您的要求.

Well, as were're here in a C# forum: we can't tell you. It depends on your requirements.

这将是一个SQL Server论坛:它取决于您的数据库设计..从XML开始,应该有三个表:

Would this be a SQL Server forum: It depends on your database design.. From the XML there should be three tables:

人事,人事内部和人事部门.由于我不是母语人士,所以可能会有更好的名字.

Personnel, PersonnelInternals and PersonnalDepartments. As I'm not a native speaker, there may be better names.

与人员<-1:1->人员内部和人员<-1:1/n->人事部门.

With Personnel <- 1:1 -> PersonnelInternals and Personnel <- 1:1/n -> PersonnelDepartments.

并不总是需要分隔Personnal和PersonnelInternals,但这取决于实际要求,即是否使用列权限.

The separation of Personnal and PersonnelInternals is not always necessary, but it depends on the actual requirements as using permissions on columns or not.


这篇关于将节点包含"level ="的XML文件读取到DataSet对象中.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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