This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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 Building Microservices this week in the Design 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: 13007
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.
I agree. Here's the link:
subject: How to convert a node into xml format
It's not a secret anymore!