本文介绍了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

推荐答案





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

10-24 11:51