Definitely return an Element and not a String. This is because an Element is
already in the DOM structure to be manipulated. It can at any time be
converted to a String if you want it as a String. But to go back from a
String to an Element requires parsing.
Also you should not build xml by concatenating strings, you should be
building it using Element's, Attributes and other Nodes. This is because you
dont have to worry about xml syntax and things like that, it can validate,
and also is object oriented.
Note that you will need a reference to the Document object in the method
also, because the way you make an Element is by calling
document.createElement("name"); You could either pass the document in as
another parameter, or have it as a class attribute.

-----Original Message-----
From: Khamesra, SandeepX [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 20, 2001 8:55 AM
To: [EMAIL PROTECTED]; '[EMAIL PROTECTED]'
Subject: Is this the correct design


Guys
I need to write a java function which accepts a parametr and returns the
data in the form of XML . Now this service is in Java. What dod you think is
the best design . out of these 

public Element GetMyInfo(String name )
{
/*  This function builds the XML based on some criter*/

}

or

public String GetMyInfo(String name )
{
/* Concatenate the string to give XML lok and return it */
}

Is there any better design .. This should be accessible for all types of
client using SOAP.. 

Reply via email to