Click here to Skip to main content
Sign Up to vote bad
good
See more: XMLVB.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 - 5:17

Comments
Wes Aday - 10 Aug '12 - 11:23
I would see if the bcp utility would help you import the XML.

1 solution

Assuming you are using SQL server have a read of this
 
Parse Large XML files into SQL Server[^]
  Permalink  
Comments
AlluvialDeposit - 10 Aug '12 - 11:30
5'd
Simon_Whale - 10 Aug '12 - 14:29
Thank you
Sergey Alexandrovich Kryukov - 10 Aug '12 - 14:10
I checked the answers -- they are adequate, a 5. --SA
Simon_Whale - 10 Aug '12 - 14:29
Thanks SA
losmac - 10 Aug '12 - 15:39
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
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 333
1 OriginalGriff 261
2 Mohammed Hameed 198
3 Mayur_Panchal 153
4 Dave Kreskowiak 125
0 Sergey Alexandrovich Kryukov 8,171
1 OriginalGriff 6,236
2 CPallini 3,482
3 Rohan Leuva 2,703
4 Maciej Los 2,234


Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 10 Aug 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid