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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:45:22+00:00 2026-05-13T11:45:22+00:00

i am getting little bit lost with all the XML handling methods in java,

  • 0

i am getting little bit lost with all the XML handling methods in java, xpath, sax, DOM, DocumentBuilderFactory…different buzz words that i dont see how they relate…

1) so i am guessing my question is
any one knows a good tutorial about handling XML in java 6?, i have found a few but they seem to be old.

2) i need to traverse a xml tree, meaning to be aware of it different nodes and be able to take data from it, what is the best way to do it?

thanks

any link would be appreciated

  • 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-13T11:45:22+00:00Added an answer on May 13, 2026 at 11:45 am

    There are several different XML technologies in Java, all of them fundamentally doing the same thing (providing some manner of access to the XML tree), but all of them in mostly different ways.

    The original technique, SAX, is a streaming XML processor. Simply, you fire up the parser and the parser makes callbacks in to your code as it encounters various XML elements. The key here is that it is processing XML elements, not YOUR XML elements. That is, it will tell you when it’s going to see a new XML element (any XML element), or a block of text, rather than the ORDER element, or the ITEM element. SAX sees XML at just above the token level, it’s up to your program to actually build an in memory representation from that tree.

    Next up, is DOM. Domain Object Model. This is a technique familiar to web developers. It begins by consuming the entire XML document in to memory and, unlike SAX, it returns a reference to the in memory model — a combination of nodes and pointers to other nodes. You can readily walk the DOM tree to find your information, but it is a generic model. The advantage of the DOM model is that you do get the entire document in a single form. The disadvantage is that you, well, get the entire document in a single form. It’s nice for smaller documents, not so good for enormous ones.

    Of course, it all depends on what you want from the document. If you truly need all of the information from the document, then you may as well load the entire thing in to memory. If you only need a subset, then a streaming processor may be a better solution, particularly for large documents.

    The combination of the too is a technology called StAX, which basically give a “DOM” like view, to a streamed XML document. What this means is that you can worked with XML document much like you would a DOM document, but the parser will lazily load up the information that you want to extract, which can ideally lower overall memory impact. So it’s a combination of the 2 above techniques.

    For both DOM and StAX, there is a technique available to access the data called “XPath”. XPath is a query language to give you access to the individual elements, but in a declaratory way. You can consider XPath the same way you would consider a file name path on your hard disk. Without XPath you would need to start at the root of the XML document, and “crawl” the tree to get to and extract your information. XPath abstracts this process for you, and it can helps avoid much of the noise of an XML document, especially when you’re after a subset of a larger document.

    Finally, with Java, there is a technology called “JAXB”, which is an XML binding technology. This is used to map Java classes to and from XML. You point the system at an XML document, and you get Java classes back. Or, you point a Java class instance at the system, and you can get XML back. For basic cases, I find JAXB quite easy to use, especially when I have control over both the Java classes and the resulting XML. Also, there are other, 3rd party XML binding systems similar to JAXB, but JAXB comes with Java 6.

    As to which one you need, that’s really up to you.

    Most folks avoid SAX today, as it’s a bit of a pain to actually use. It’s fast, and cheap, but can be time consuming as a programmer.

    DOM and XPath is likely the most common technique today, particularly because of it’s similar to modern web page programming and how the browsers work with XML. If you have smaller documents (less than 50-100K), and particularly if you only need a subset of the data, DOM and XPath are quite capable and straightforward to use.

    If you plan one working at a higher level, and need to work with the entire document, as well as read and write XML, then JAXB may be of interest. My only concern is that mapping a legacy XML document to classes is a bit more complicated, and you may not get early success trying to do that.

    All of these have good guides available, and I won’t provide links. Rather you can use this guide to focus on the particular XML technology that you think would suit your application best, and go from there.

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

Sidebar

Ask A Question

Stats

  • Questions 404k
  • Answers 404k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer An indispensible source of information in this regard http://www.wotsit.org .… May 15, 2026 at 5:28 am
  • Editorial Team
    Editorial Team added an answer I'd guess this question is best answered by the standard… May 15, 2026 at 5:28 am
  • Editorial Team
    Editorial Team added an answer Printing -- using the PrintDocument API your user will be… May 15, 2026 at 5:28 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.