File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes How to convert a node into xml format Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to convert a node into xml format" Watch "How to convert a node into xml format" New topic

How to convert a node into xml format

Raghunath Nandyala
Ranch Hand

Joined: Jan 24, 2006
Posts: 64

Im having one node (Element) say root, How to convert this into a string that represents XML format data like <root></root>.

Raghunath N

Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
You can use xslt for this.

Rahul Bhattacharjee
LinkedIn - Blog
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12769
Presumably you have the name of the Node, why not just build a String with that name? No need to fire up XSLT.
Note that if there is text content contained by that Element you will have to extract the Text node that holds the content.
Consider Paul's rocket mass heater.
subject: How to convert a node into xml format