Click here to Skip to main content
13,152,454 members (39,487 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
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:17am
Comments
Wes Aday 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 10-Aug-12 11:30am
   
5'd
Sergey Alexandrovich Kryukov 10-Aug-12 14:10pm
   
I checked the answers -- they are adequate, a 5.
--SA
Simon_Whale 10-Aug-12 14:29pm
   
Thank you
Simon_Whale 10-Aug-12 14:29pm
   
Thanks SA
losmac 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
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web01 | 2.8.170924.2 | Last Updated 10 Aug 2012
Copyright © CodeProject, 1999-2017
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