Value of the root element in XML file using JDOM.

Posted on 2006-07-10
Last Modified: 2011-10-03
When I print the value of a root element "root is not leaf, so it has children" by getValue() method in JDOM, the output was spaces with new lines.

I want to knew:
 what is the value of root element?
Question by:javamate06
LVL 86

Expert Comment

ID: 17076621
It won't have a value - it has child nodes
LVL 92

Expert Comment

ID: 17077851
please post you xml and your code
LVL 23

Expert Comment

ID: 17078491
did you try calling


on the element.
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

LVL 10

Accepted Solution

mukundha_expert earned 50 total points
ID: 17078977
root.getText () ;

Author Comment

ID: 17079199

I tried getTextTrim() but the problem is that the defferent roots have differenet value "Spaces and multi new lines".
LVL 23

Expert Comment

ID: 17079273
> defferent roots have differenet value
XML document can have ONLY ONE root element.

Author Comment

ID: 17079312
XML has one root and the roots of children, and the roots of grand-children.
lets call them heads not root.

LVL 23

Expert Comment

ID: 17079411
i am confused ;)

Can you pls post the xml?

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
servlet doXXX methods 3 62
Oracle SQL syntax check  without executing 6 75
Eclipse Help Java EE 5,6,7 Documentation, why not Java EE 8 8 30
java mysql insert application 14 29
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question