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 8794265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:13:42+00:00 2026-06-13T23:13:42+00:00

I have a huge xml file (40 gbs). I would like to extract some

  • 0

I have a huge xml file (40 gbs). I would like to extract some fields from it without loading the entire file into memory. Any suggestions?

  • 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-13T23:13:43+00:00Added an answer on June 13, 2026 at 11:13 pm

    A quick example with XMLEventReader based on a tutorial for SAXParser here (as posted by Rinat Tainov).

    I’m sure it can be done better but just to show basic usage:

    import scala.io.Source
    import scala.xml.pull._
    
    object Main extends App {
      val xml = new XMLEventReader(Source.fromFile("test.xml"))
    
      def printText(text: String, currNode: List[String]) {
        currNode match {
          case List("firstname", "staff", "company") => println("First Name: " + text)
          case List("lastname", "staff", "company") => println("Last Name: " + text)
          case List("nickname", "staff", "company") => println("Nick Name: " + text)
          case List("salary", "staff", "company") => println("Salary: " + text)
          case _ => ()
        }
      }
    
      def parse(xml: XMLEventReader) {
        def loop(currNode: List[String]) {
          if (xml.hasNext) {
            xml.next match {
              case EvElemStart(_, label, _, _) =>
                println("Start element: " + label)
                loop(label :: currNode)
              case EvElemEnd(_, label) =>
                println("End element: " + label)
                loop(currNode.tail)
              case EvText(text) =>
                printText(text, currNode)
                loop(currNode)
              case _ => loop(currNode)
            }
          }
        }
        loop(List.empty)
      }
    
      parse(xml)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a huge xml file that I would like to split up into
I have got a huge xml file (~ 85 Mo) and I would like
I have a thousands of data parsed from huge XML to be inserted into
As the title says it, I have a huge xml file (GBs) <root> <keep>
I am loading a huge amount of data from an XML file. This data
I have a simple but huge xml file like below. I want to parse
I have a huge xml file (1 Gig). I want to move some of
I have a huge checkbox list with different levels and I would like to
So I have this huge XML file that I am converting to an object
I have this very huge XML file of size 2.8GB. This is Polish Wikipedia's

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.