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

  • SEARCH
  • Home
  • 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 7509465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:55:35+00:00 2026-05-29T22:55:35+00:00

I’m trying to use XStream to import large XML files (~ 1 GB). I

  • 0

I’m trying to use XStream to import large XML files (~ 1 GB). I want to use an ObjectInputStream to read them streaming, but I need that to skip the first element and then move down a couple elements (see below, I need to import the bag_LVC:Woonplaats elements).

I’d expect that there is somehow a way to feed xstream a Reader or a InputStream which has been seeked up to my element of interest. I’ve tried to create my own HierarchicalStreamReader and move it to the right element, but you can only move up and down:

HierarchicalStreamReader xpp = new XppDriver().createReader(xmlFile);
xpp.moveDown(); // moves to <xb:antwoord>
xpp.move(); // **would move to <xb:producten>, but it private**
xpp.moveDown(); // moves to <xb:producten>
xpp.moveDown(); // moves to <product_LVC:LVC-product>
st = xstream.createObjectInputStream(xpp);
BagWoonplaats bw = (BagWoonplaats) st.readObject();

Does xstream or any of the XPP drivers have any way to let you seek to my element of interest?

xml

<xb:BAG-Extract-Deelbestand-LVC>
  <xb:antwoord>
    <xb:vraag>
    <!-- more elements here -->
    </xb:vraag>
    <xb:producten>
      <product_LVC:LVC-product>
        <bag_LVC:Woonplaats>
          <!-- elements used as fields -->
        </bag_LVC:Woonplaats>
        <bag_LVC:Woonplaats>
          <!-- elements used as fields -->
        </bag_LVC:Woonplaats>
        <!-- and so on -->
  • 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-05-29T22:55:38+00:00Added an answer on May 29, 2026 at 10:55 pm

    The solution for this problem was actually very trivial, and I’m almost embarrassed, but let’s share the answer for this problem anyway. I didn’t get the API for the HierarchicalStreamReader, after digging around in the code of XStream I managed to get an handled to it, this is how it works:

        HierarchicalStreamReader xpp = ...;
        while(xpp.hasMoreChildren()) {
            xpp.moveDown();
            // do something with the child element, and recursive into this again if appropriate
            xpp.moveUp();
        }
    

    This is recursive method I now use to seek to the appropriate element. The location is specified by a sort of xpath expression (very basic, of course), which I have normalized in advance, into an ArrayList:

    private void seekToElement(HierarchicalStreamReader xpp, ArrayList<String> xpathishArray) {
        while(xpp.hasMoreChildren()) {
            xpp.moveDown();
            if(xpp.getNodeName().equals(xpathishArray.get(0))) {
                if(xpathishArray.size() > 1) {
                    xpathishArray.remove(0);
                    seekToElement(xpp, xpathishArray);
                }
                return;
            }
            xpp.moveUp();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I need to clean up various Word 'smart' characters in user input, including but
I want to construct a data frame in an Rcpp function, but when I
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have thousands of HTML files to process using Groovy/Java and I need to
Basically, what I'm trying to create is a page of div tags, each has

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.