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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:14:39+00:00 2026-05-23T09:14:39+00:00

I came across two different codes for parsing a file with StAX . A

  • 0

I came across two different codes for parsing a file with StAX. A quick googling told me that there are 2 ways to parse : using cursor API and using iterator API. Please tell me the difference between the two and which one is easier to use from developer point of view.

  • 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-23T09:14:40+00:00Added an answer on May 23, 2026 at 9:14 am

    You’re most likely to find the answer in the StAX API sections within the Java Web Services Developer Pack tutorial or Java EE 5 tutorial. Both of them contain the same information that I am reproducing below:

    Comparing Cursor and Iterator APIs

    Before choosing between the cursor and
    iterator APIs, you should note a few
    things that you can do with the
    iterator API that you cannot do with
    cursor API:

    • Objects created from the XMLEvent subclasses are immutable, and can be
      used in arrays, lists, and maps, and
      can be passed through your
      applications even after the parser has
      moved on to subsequent events.

    • You can create subtypes of XMLEvent that are either completely
      new information items or extensions of
      existing items but with additional
      methods.

    • You can add and remove events from an XML event stream in much simpler
      ways than with the cursor API.

    Similarly, keep some general
    recommendations in mind when making
    your choice:

    • If you are programming for a particularly memory-constrained
      environment, like J2ME, you can make
      smaller, more efficient code with the
      cursor API.

    • If performance is your highest priority–for example, when creating
      low-level libraries or
      infrastructure–the cursor API is more
      efficient.

    • If you want to create XML processing pipelines, use the iterator
      API.

    • If you want to modify the event stream, use the iterator API.

    • If you want to your application to be able to handle pluggable processing
      of the event stream, use the iterator
      API.

    • In general, if you do not have a strong preference one way or the
      other, using the iterator API is
      recommended because it is more
      flexible and extensible, thereby
      “future-proofing” your applications.

    The iterator API although recommended is slower than the cursor API, as the cursor does not need to remember the previous nodes that it had parsed; it provides forward-only parsing of XML documents and does not have the overhead of construction of XMLEvent objects. Apparently, a benchmark has indicated that SAX might turn out to be better at parsing large documents compared to StAX; you might want to verify if you can reproduce the results of the benchmark for your data-sets.

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

Sidebar

Related Questions

No related questions found

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.