Link to home
Start Free TrialLog in
Avatar of julie_456
julie_456

asked on

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
Avatar of mukundha_expert
mukundha_expert

use a transformer
ASKER CERTIFIED SOLUTION
Avatar of mukundha_expert
mukundha_expert

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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)));
Avatar of CEHJ
If you want a quick and dirty way, see how it's done here:

http://technojeeves.com/joomla/index.php/free/63-xpath-tester
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