Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a huge (250MB+) xml file that I need to parse into a database. Here is an example of the file:

XML
<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
Comments
[no name] 10-Aug-12 11:23am    
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[^]
 
Share this answer
 
Comments
StianSandberg 10-Aug-12 11:30am    
5'd
Simon_Whale 10-Aug-12 14:29pm    
Thank you
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    
Thanks SA
Maciej Los 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900