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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:01:06+00:00 2026-05-25T18:01:06+00:00

Since getting text content from an xml element requires 15 lines of code (see

  • 0

Since getting text content from an xml element requires 15 lines of code (see official oracle tutorial) here http://java.sun.com/webservices/reference/tutorials/jaxp/html/dom.html , the quoted tutorial itself suggests, for many needs to use thirdy party tools:

“As you can see, when you are using DOM, even a simple operation such as getting the text from a node can take a bit of programming. So if your programs handle simple data structures, then JDOM, dom4j, or even the 1.4 regular-expression package (java.util.regex) may be more appropriate for your needs”

I’ve tried the suggested tools and they are reasonably easy to use and complete BUT they require an evaluation of the “vitality” of their developement
. And this evaluation is not ever obvious.
So my questions are:

1) is there a library that eases xml work, built on top of standard dom? it would ensure the robusteness and up-to-dateness of official library with more usability
2) is this “usability” lack about to be adressed in some other way (perhaps some new jsr?), in the oracle plans?

  • 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-25T18:01:06+00:00Added an answer on May 25, 2026 at 6:01 pm

    If getting text content from XML elements is what you want, use XPath:

        String xml = "<root><p>This is some text</p><p>And this is more text</p></root>";
        XPath xpath = XPathFactory.newInstance().newXPath();
        String text = xpath.evaluate("/root/p[1]", new InputSource(
                new StringReader(xml)));
        System.out.println(text);
    

    If you want to map Java objects to XML and back, use JAXB.

    Both XPath (1.0) and JAXB are part of the JDK, or they can be replaced with later versions.

    However, if you try to parse XML with regular expression, you are doomed!

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

Sidebar

Related Questions

I'm not sure why I'm getting this error, but shouldn't this code compile, since
The code #!/usr/bin/env python import MySQLdb print Content-Type: text/html print print <html><head><title>Books</title></head> print <body>
I am using this code to fetch my changelog from the net. InputStream content
i am here with another problem in my code since i am new to
Since getting a satisfactory answer on SuperUser is very difficult, I want to rephrase
It has been quite a while since I am getting this error in the
I am getting some open/closed times as integers since midnight. For example: 1140 =
Ever since deleting the original settings.settings file I have had endless problems getting the
Since upgrading to the latest Xcode 3.2.1 and Snow Leopard, I've been getting the
I've been doing some cocoa since a week, and I'm getting kinda good with

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.