Transform XML JDOM to String

I have a program in which I've created a JDOM document with various elements.  I want to take the JDOM Document and extract the stuff inside the element tags ( these things <>) as a string.  Any suggestions?

I don't know if I need to use the JDOM transformer or the javax.xml transformer.  I don't know how to use either one.  Any help would be fantastic.

Here's some of my code:

Document xml;

Element root = new ELement("Login");
Document doc = new Document(root);

I'm getting this when I print the document to the console:

I need to get myName in a string format.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can either taverse the JDOM document or write a XSL stylesheet.  Traversal should be easier
  Element loginElement=(Element)doc.getChild("Login");
  String loginValue =  loginElement.getText();

To use the transformer, I would suggest using the JAXP API.  It will work if you decide to use the W3C DOM with no changes:

   StreamSource xslSource=new StreamSource(new File("getLogin.xsl"));
   Transformer t=TransformerFactory.newInstance().newTransformer(xslSource);

   Source xmlSource=new JDOMSource(doc);
   Result out=new StreamResult(System.out);
   t.transform(xmlSource, out);

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="" xmlns:fo="">
    <xsl:template match='/'>
          <xsl:value-of select='//Login'/>

trevorhigbee2000Author Commented:
When I do:

Element loginElement=(Element)doc.getChild("Login");

I get an error:
"The method getChild(String) is undefined for the type Document."

you first need to get the element (node) from the document, then only you can access the individual properties and/or child nodes.  so do this...

Element root = doc.getRootElement();
String childText = root.getChildText( "Login" );


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.