如何读取此250 + MB .xml文件 [英] How to read this 250+MB .xml file
本文介绍了如何读取此250 + MB .xml文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个巨大的(250MB +)xml文件,需要将其解析到数据库中.这是文件的示例:
I have a huge (250MB+) xml file that I need to parse into a database. Here is an example of the file:
<MYmaps_Records xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="MYmaps.xsd">
<MYMapRecord>
<MYmapId>MAP1</MYmapId>
<LabelLine1>1</LabelLine1>
<LabelLine2>MAP</LabelLine2>
<MinLatitude>25500000N</MinLatitude>
<MaxLatitude>36100000N</MaxLatitude>
<MinLongitude>074000000W</MinLongitude>
<MaxLongitude>091000000W</MaxLongitude>
<MYMapObjectType>
<MapObjectType>ExtraLine</MapObjectType>
<MYMapLine>
<LineObjectId>ExtraLine1</LineObjectId>
<LineObjectSeq>1</LineObjectSeq>
<Color>White</Color>
<LineStyle>Solid</LineStyle>
<Thickness>1</Thickness>
<StartLatitude>29413369N</StartLatitude>
<StartLongitude>083000853W</StartLongitude>
<MYTextFilters>
<FilterGroup>8</FilterGroup>
</MYTextFilters>
<MYTextStrings>
<TextLine>Extra Line 1</TextLine>
</MYTextStrings>
</MYMapLine>
<MYMapLine>
<LineObjectId>ExtraLine2</LineObjectId>
<LineObjectSeq>2</LineObjectSeq>
<Color>White</Color>
<LineStyle>Solid</LineStyle>
<Thickness>1</Thickness>
<StartLatitude>29414120N</StartLatitude>
<StartLongitude>083000854W</StartLongitude>
<MYTextFilters>
<FilterGroup>8</FilterGroup>
</MYTextFilters>
<MYTextStrings>
<TextLine>Extra Line 2</TextLine>
</MYTextStrings>
</MYMapLine>
<MYMapLine>
<LineObjectId>ExtraLineX</LineObjectId>
<LineObjectSeq>3</LineObjectSeq>
<Color>White</Color>
<LineStyle>Solid</LineStyle>
<Thickness>1</Thickness>
<StartLatitude>29414121N</StartLatitude>
<StartLongitude>082595993W</StartLongitude>
<EndLatitude>29413370N</EndLatitude>
<EndLongitude>082595992W</EndLongitude>
<MYTextFilters>
<FilterGroup>8</FilterGroup>
</MYTextFilters>
<MYTextStrings>
<TextLine>Extra Line x</TextLine>
</MYTextStrings>
</MYMapLine>
'Thousands more MYMapLIne
</MYMapObjectType>
'Hundreds more MYMapObjectType
</MYMapRecord>
<MYMapRecord>
<MYmapId>MAP2</MYmapId>
<LabelLine1>2</LabelLine1>
<LabelLine2>MAP</LabelLine2>
<MinLatitude>25500000N</MinLatitude>
<MaxLatitude>36100000N</MaxLatitude>
<MinLongitude>074000000W</MinLongitude>
<MaxLongitude>091000000W</MaxLongitude>
<MYMapObjectType>
<MapObjectType>ExtraLineAA</MapObjectType>
<MYMapLine>
<LineObjectId>ExtraLine1</LineObjectId>
<LineObjectSeq>1</LineObjectSeq>
<Color>White</Color>
<LineStyle>Solid</LineStyle>
<Thickness>1</Thickness>
<StartLatitude>29413369N</StartLatitude>
<StartLongitude>083000853W</StartLongitude>
<MYTextFilters>
<FilterGroup>8</FilterGroup>
</MYTextFilters>
<MYTextStrings>
<TextLine>Extra Line 1</TextLine>
</MYTextStrings>
</MYMapLine>
<MYMapLine>
<LineObjectId>ExtraLine2</LineObjectId>
<LineObjectSeq>2</LineObjectSeq>
<Color>White</Color>
<LineStyle>Solid</LineStyle>
<Thickness>1</Thickness>
<StartLatitude>29414120N</StartLatitude>
<StartLongitude>083000854W</StartLongitude>
<MYTextFilters>
<FilterGroup>8</FilterGroup>
</MYTextFilters>
<MYTextStrings>
<TextLine>Extra Line 1</TextLine>
</MYTextStrings>
</MYMapLine>
<MYMapLine>
<LineObjectId>ExtraLineX</LineObjectId>
<LineObjectSeq>3</LineObjectSeq>
<Color>White</Color>
<LineStyle>Solid</LineStyle>
<Thickness>1</Thickness>
<StartLatitude>29414121N</StartLatitude>
<StartLongitude>082595993W</StartLongitude>
<EndLatitude>29413370N</EndLatitude>
<EndLongitude>082595992W</EndLongitude>
<MYTextFilters>
<FilterGroup>8</FilterGroup>
</MYTextFilters>
<MYTextStrings>
<TextLine>Extra Line 1</TextLine>
</MYTextStrings>
</MYMapLine>
'Thousands more MYMapLIne
</MYMapObjectType>
'Hundreds more MYMapObjectType
</MYMapRecord>
'Many more MYMapRecord
</MYmaps_Records>
我一直在尝试使用xmlreader并获取元素名称和数据,但是寻找开始到结束标签确实很麻烦.顺便说一句:我无法控制XML的结构,所以我必须按原样使用它.
I have been trying to use xmlreader and get the element names and data but it get really combersome looking for beginning end ending tags. BTW: I have no control of the structure of the XML so I have to work with it the way it is.
Is there an easy way to read/parse this file?
推荐答案
假设您正在使用SQL Server,请阅读此文件.
将大型XML文件解析为SQL Server [ ^ ]
Assuming you are using SQL server have a read of this
Parse Large XML files into SQL Server[^]
这篇关于如何读取此250 + MB .xml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文