Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8903725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:56:26+00:00 2026-06-15T01:56:26+00:00

I need to parse an XML file and store the data to sql server

  • 0

I need to parse an XML file and store the data to sql server in vb.net. I have been reading online and it seems that I should use xmltextReader class to read the file, since this will eliminate the out of memory issue. I started something like following. I need feedback that am I doing OK or should I used some other way that will be easier. Sample XML file goes like this

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<MainElement>
    <MainEle1>
        <InfoA>
            <InfoAId>121480431A</InfoAId>
            <firstName>Anne</firstName>
            <lastName>Stevens</lastName>
            <phone>6023122456</phone>
            <address>
                <address1>8735 Elm Road</address1>
                <address2></address2>
                <city>Nowhere</city>
                <country></country>
                <state>CA</state>
                <suite></suite>
                <zipCode>30141</zipCode>
            </address>
            <dob>09/08/1982</dob>
            <gender></gender>
            <primaryLanguage>Other</primaryLanguage>
            <otherLanguage>french</otherLanguage>
            <planName></planName>
            <contacts>
                <firstName>rajesh</firstName>
                <lastName>raj</lastName>
                <phone>1232343241</phone>
                <address>
                    <address1></address1>
                    <address2></address2>
                    <city></city>
                    <country></country>
                    <state></state>
                    <suite></suite>
                    <zipCode></zipCode>
                </address>
                <contactType>EMERGENCY</contactType>
                <relationship>friend</relationship>
                <typeDesc>Emergency Contact/Next of Kin</typeDesc>
            </contacts>
         </InfoA>
    </MainEle1>
    <MainEle2>
        <subMainEle2>
            <firstName>victor</firstName>
            <lastName>john</lastName>
            <phone>1233455678</phone>
            <address>
                <address1>123 arrow</address1>
                <address2></address2>
                <city>upland</city>
                <country></country>
                <state>ca</state>
                <suite>234</suite>
                <zipCode>76547</zipCode>
            </address>
            <contactType>PRIMARY</contactType>
            <relationship></relationship>
            <typeDesc></typeDesc>
        </subMainEle2>
    </MainEle2>
    <MainEle3>
    ..
    </MailEle3>
    <MainEle4>
    ..
    </MailEle4>
    ..
</MainElement>

Dim reader As XmlTextReader
reader = New XmlTextReader("c:\FileName")

While Not reader.EOF
    Select Case reader.NodeType
    Case XmlNodeType.Element 
        Select Case reader.Name
        Case "MainEle1"
            Call ProcessMainEle1(reader) ' passing reader as ref
        Case "MainEle2"
            call ProcessMainEle2(reader) ' passing reader as ref
        Case "MainEle3"
            call ProcessMainEle3(reader) 'passing reader as ref
                 ' and read many element
        End Select
    End Select
End While

and in Process method I am using similar approach and creating the insert statement.
Is that the right approach or is there a simple approach for large file with many element within elements. I would appreciate guidance for novice programmer

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:56:27+00:00Added an answer on June 15, 2026 at 1:56 am

    For your use case It is important to use an XML Parser which is not DOM based. (SAXParser)

    From memory consumption point of view there is nothing worse in IT than a DOM based XML parser. Such a parser will need 100 – 1000 times more memory than a low level parsing, which is more work for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file which I need to parse using PHP and send
I need to parse an xml file in java and store it in an
I need to get data from an XML file and store it into a
well i have a xml file that i use to store location names with
I have an XML file that I am trying to parse with Sax (this
I have a ~1GB XML file that has XML tags that I need to
I have some static xml data that I want to read once and store
I need to parse a bunch of incoming xml documents, they all have the
I need to parse a XML file which I get from third party to
I am parsing through a XML file that's about 12mb big. I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.