XML到DataSet [英] XML to DataSets

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

问题描述

大家好,


我已经获得了一个XML文件(12 MB),我需要从中提取数据。

XML文件使数据易于查看,但数据无法以当前格式分析

。我已经看了很多XMLTextReader的东西,而且我不知道如何提取如何提取我想要的信息。这里是XML格式的快速

示例:


< instance identity =" A1"名称= QUOT; A1" type =" A_Type">

< attribute Name =" AttA1-1">

< value>

X

< / value>

< / attribute>

< instance identity =" B1"命名= QUOT; B1" type =" B_Type">

< attribute Name =" AttB1-1">

< value>

X

< / value>

< / attribute>

< instance identity =" B2"命名= QUOT; B2" type =" B_Type">

< attribute Name =" AttB2-1">

< value>

X

< / value>

< / attribute>

< instance identity =" C1"名称= QUOT; C1" type =" C_Type">

< attribute Name =" AttC1-1">

< value>

X

< / value>

< / attribute>

< / instance>

< /实例>

< / instance>

< / instance>


每个A_Type包含多个B_Types,每个B_Type包含几个
C_Types和该文件包含许多A_Types。我已经展示了一个属性

,但每种类型都有很多属性!


我想做的就是加载这个使用Master-Detail将数据分成几个表

Releations。因此,表A将包含每个A_Type的行加上它的'/ b $ b属性(使用属性名称作为列标题)。对于表A中选择的给定行

,表B将显示每个B_Types和它的

属性等。


那么,是否有一种简单的方法可以使用

XMLTextReader或其他一些漂亮的XML工具从文件中获取数据,或者这将是一个粗暴的

使用正则表达式和do循环的方法吗?


我不确定我是否提供了足够的信息,所以如果你需要了解一些东西

否则你可以给我一个答案,请告诉我!如果它要蛮力,那就没问题,但是我不想花几天时间编码,只有

以后才能找到有一个快速的方法来做到这一点!


TIA

Lee

Hi All,

I''ve been given an XML file (12 MB) that I need to extract data from. The
XML file makes the data easy to view, but the data is impossible to analyze
in its current format. I''ve looked at lots of XMLTextReader stuff and I
can''t seem to figure out how to extract the info that I want. Here''s a quick
example of the XML format:

<instance identity="A1" name="A1" type="A_Type">
<attribute Name="AttA1-1">
<value>
X
</value>
</attribute>
<instance identity="B1" name="B1" type="B_Type">
<attribute Name="AttB1-1">
<value>
X
</value>
</attribute>
<instance identity="B2" name="B2" type="B_Type">
<attribute Name="AttB2-1">
<value>
X
</value>
</attribute>
<instance identity="C1" name="C1" type="C_Type">
<attribute Name="AttC1-1">
<value>
X
</value>
</attribute>
</instance>
</instance>
</instance>
</instance>

Each A_Type contains several B_Types, and each B_Type contains several
C_Types and the file contains lots of A_Types. I''ve shown one attribute
each, but there are lots of them for each type!

what I''d like to do is load this data into a few tables with Master-Detail
Releations. So Table A would contain a row for each A_Type plus it''s
attributes (with the Attribute Name as the Column Header). For a given row
selected in Table A, Table B would show each of the B_Types and it''s
attributes, etc.

So, is there an easy way to get the data from the file using an
XMLTextReader or some other nifty XML tool, or is this going to be a brute
force method with regular expressions and do loops?

I''m not sure if I''ve supplied enough info, so if you need to know something
else before you can give me an answer, please let me know!! If it''s going to
be brute force, that''s fine, but I''d hate to spend a few days coding, only
later to find out that there was a quick way to do this!

TIA
Lee

推荐答案

lgbjr,


您可以随时尝试在IDE中将其作为文件打开,而不是获得一些

信息。


Cor
lgbjr,

You can always try to open it as file in your IDE, than you get than some
information.

Cor


Cor,


我明白了。我可以在IE中打开文档,我可以将它导入到

Excel中,但在这两种情况下,格式都很适合查看,但不适用于数据

分析。数据的呈现方式是表格式,而不是列式。

所以,如果我想查看每个Type_C的特定属性,我有很多

的向上滚动并向下比较值。理解?


我需要的是将XML文件转换为数据集,每个都有一个表
类型,类型中每个属性的列,和每个实例的行

类型。


我已经找到了很多关于从

创建XML文档的信息现有的数据集,但没有任何运气找到任何关于

从现有XML文档创建数据集的运气。我知道我可以手动执行此操作

(通过文件,查找所有类型(表格)和

属性(列),但我希望那里是一个可用的工具

会为我做这个(输入到工具将是XML文档,

输出将是一个数据集)或者我会对MDB文件或SQL DB感到满意,

虽然我真的只需要数据集,因为数据已存储在XML文件中的
磁盘上(无需存储2个位置的数据!)

一旦我有了数据集,我就可以将XML文档加载到数据集中,并且

做任何分析。我希望能够做的是

动态生成数据集(步骤1 - 读取XML文件并生成

数据集,步骤2 - 将XML文件中的数据加载到数据集中。

有一个工具可以做到这一点.VB.NET可以这样做吗?或者我必须手动

创建d首先是ataset,然后加载XML文件中的数据?


TIA

Lee

" Cor Ligthert" <无************ @ planet.nl>在消息中写道

news:uT ************** @ TK2MSFTNGP09.phx.gbl ...
Cor,

this I understand. I can open the document in IE, I can import it into
Excel, but in both cases, the format is nice for viewing, but not for data
analysis. the way the data is presented is tabular, rather than columnar.
So, If I want to look at a particular attribute for each Type_C, I have lots
of scrolling up and down to compare the values. Understand?

what I need is to convert the XML file to a dataset, with a table for each
Type, columns for each atrribute in the Type, and rows for each instance of
the Type.

I have found lots of information for creating an XML document from an
existing Dataset, but have not had any luck finding anything regarding
creating a dataset from an existing XML document. I know I can do this
manually (going through the file, finding all of the Types (tables), and
attributes (columns), but I was hoping that there was a tool available that
would do this for me (Input to the tool would be the XML document, the
output would be a dataset) Or I''d be happy with an MDB file or SQL DB,
though I really only need the dataset since the data is already stored on
disk in the XML file (No need to store the data in 2 locations!)

Once I have the dataset, I can "Load" the XML document into the dataset and
do whatever analysis that is required. What I''d like to be able to do is to
dynamically generate the dataset (Step 1 - read the XML file and generate
the dataset, Step 2 - load the data from the XML file into the dataset). Is
there a tool that can do this. Can VB.NET do this? Or do I have to manually
create the dataset first, then load the data from the XML file?

TIA
Lee
"Cor Ligthert" <no************@planet.nl> wrote in message
news:uT**************@TK2MSFTNGP09.phx.gbl...
lgbjr,

您可以随时尝试在IDE中将其作为文件打开,而不是获取一些
信息。

Cor
lgbjr,

You can always try to open it as file in your IDE, than you get than some
information.

Cor



lgbjr,


您是否在解决方案中进行了探索:添加现有项目,选择XML,以及

而不是浏览到您的XLM文件?


Cor
lgbjr,

Did you do in your solution explorere: add existing item, choose XML , and
than browse to your XLM file?

Cor


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

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