Return an XML as a String

M

Maximiliano Barone

I would like to return an XML with all its tags in a String (I am
developing with Java).
I have built the Document in a DOM an then I want to convert it into a
String.

public String MyWebService (String parameter)
{}

Thanks in advance.

MDB
 
J

Johannes Koch

Maximiliano said:
I would like to return an XML with all its tags in a String (I am
developing with Java).
I have built the Document in a DOM an then I want to convert it into a
String.

This is called serialization. If you use Xerces, you can use Xerces'
serialization classes.
 
G

GIMME

You can use JDOM to do it ...

Use the DOMBuilder class to turn the DOM tree to a JDOM tree.

Then use JDOM's XMLOutputter class (with the "" indent option
to create the XML as a string) and the method outputString method
to write the XML.

IMO, if you are using Java and DOM, you'd gain a lot by
just using JDOM and passing on DOM.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top