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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:04:28+00:00 2026-05-31T06:04:28+00:00

I am storing data for ranking users in XML documents – one row per

  • 0

I am storing data for ranking users in XML documents – one row per user – containing a 36 char key, score, rank, and username as attributes.

<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE Ranks [<!ELEMENT Rank ANY ><!ATTLIST Rank id ID #IMPLIED>]>
<Ranks>
..<Rank id="<userKey>" score="36.0" name="John Doe" rank=15></Rank>..
</Ranks>

There are several such documents which are parsed on request using a DOM parser and kept in memory until the file is updated. This happens from within a HttpServlet which is backing a widget. Every time the widget is loaded it calls the servlet with a get request which then requires one of the documents to be queried. The queries on the documents require the following operations:

  • Look up – finding a particular ID
  • Iterate through each Rank element and get the id attribute

In my test environment the number of users is <100 and everything works well. However we are soon supposed to be delivering to a system with 200K+ users. I have serious concerns about the scalability of my approach – i.e. OutOfMemoryException!

I’m stuck for ideas for an implementation which balances performance and memory usage. While DOM is good for find operations it may choke because of the large size. I don’t know much about StAX, but from what I have read it seems that it might solve the memory issue but could really slow down the queries as I will have to effectively iterate through the document to find the element of interest (Is that correct?).

Questions:

  • Is it possible to use StAX for multiple find (like getElementById) operations on large documents quick enough to serve an HttpRequest?
  • What is the maximum file size that a DOM Parser can handle?
  • Is it possible to estimate how much memory per user would be used for an XML document with the above structure?

Thanks

Edit: I am not allowed to use databases.

Edit: Would it be better/neater to use a custom formatted file instead and use Regular expressions to search the file for the required entry?

  • 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-31T06:04:29+00:00Added an answer on May 31, 2026 at 6:04 am

    It sounds like you’re using the xml document as a database. I think you’ll be much happier using a proper database for this, and importing/exporting to xml as needed. Several databases work well, so you might as well use one that’s well supported, like mysql or postgresql, although even sqlite will work better than xml.

    In terms of SAX parsing, you basically build a large state machine that handles various events that occur while parsing (entering a tag, leaving a tag, seeing data, etc.). You’re then on your own to manage memory (recording the data you see depending on the state you’re in), so you’re correct that it can have a better memory footprint, but running a query like that for every web request is ridiculous, especially when you can store all your data in a nice indexed database.

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

Sidebar

Related Questions

In which cases storing data as XML is preferable to RDBMS and why? Can
I have the option of storing data in memory either as an XML document
I am writing a program using Delphi 2006 and storing data in XML files
For storing data offline WebApp can use: session storage, advanced version of cookies key/value
I am using sqlite database for storing data. One of the table contains fields
I'm storing data in a HashMap with (key: String, value: ArrayList). The part I'm
One third party app is storing data in a huge database (SQL Server 2000/2005).
SCORM 1.2 cmi.suspend_data having limitations of storing data... can any one help me put
I often find myself storing data in a mysql database, and then wanting to
I'm storing data on baseball statistics and would like to do so with three

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.