DOM Node to XML

Can some one please let me know if there is a utility/method to convert a DOM node to an XML. I have manipulated the Node object and I want to see it's contents. Can I print it in the form of an XML?
Thank you
julie_456Asked:
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.

mukundha_expertCommented:
use a transformer
0
mukundha_expertCommented:
this code will print the XML to standard output
TransformerFactory.newInstance().newTransformer().transform(new DOMSource(node), new StreamResult(System.out) ) ;

Open in new window

0

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
Gibu GeorgeChief Technology OfficerCommented:
You can use JDOM to print the XML as it is

XMLOutputter xmlOutPutter=new XMLOutputter();
DOMBuilder domBuilder= new DOMBuilder();
System.out.println(xmlOutPutter.outputString(domBuilder.build(transformedDocument)));
0
CEHJCommented:
If you want a quick and dirty way, see how it's done here:

http://technojeeves.com/joomla/index.php/free/63-xpath-tester
0
CEHJCommented:
It's a great pity that the JDK can offer nothing better than performing an xsl tranformation as a JDK-only way of doing one of the most fundamental things in XML programming
0
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
Java

From novice to tech pro — start learning today.