Click here to Skip to main content
11,412,400 members (67,505 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: XML VB.NET
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>


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?
Posted 10-Aug-12 6:17am
Comments
Wes Aday at 10-Aug-12 11:23am
   
I would see if the bcp utility would help you import the XML.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Assuming you are using SQL server have a read of this

Parse Large XML files into SQL Server[^]
  Permalink  
Comments
AlluvialDeposit at 10-Aug-12 11:30am
   
5'd
Simon_Whale at 10-Aug-12 14:29pm
   
Thank you
Sergey Alexandrovich Kryukov at 10-Aug-12 14:10pm
   
I checked the answers -- they are adequate, a 5.
--SA
Simon_Whale at 10-Aug-12 14:29pm
   
Thanks SA
losmac at 10-Aug-12 15:39pm
   
Short and to the point, my 5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 332
1 Sascha Lefévre 200
2 Sergey Alexandrovich Kryukov 140
3 Maciej Los 135
4 ProgramFOX 130
0 Sergey Alexandrovich Kryukov 9,025
1 OriginalGriff 7,247
2 Maciej Los 3,525
3 Abhinav S 3,248
4 Peter Leow 3,059


Advertise | Privacy | Mobile
Web04 | 2.8.150414.5 | Last Updated 10 Aug 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100