• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 377
  • Last Modified:

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
0
julie_456
Asked:
julie_456
  • 2
  • 2
1 Solution
 
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
 
Gibu GeorgeCTOCommented:
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

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now