Hello,

can anyone suggest me how to convert string to xml object in java?
I have a string (Data) ant now I have to pass it as parameter as xml object, which structure should be:
<MGWData>Data</MGWData>
Where I surf I always see only solutions for converting string to xml document, but never to xml object.
maybe the problem is I don't completely understand what xml object is in first place :/

Any answer would help.
Thanks.

Maybe it's as simple as

String data = .....
String dataXML = "<MGWData>" + data + "</MGWData>";

I don't thinks so. Method, which I should use, takes xml object, not a string.
Thanks though.

Look up JDom, it's a java developed XML parser and writer API.
Depending on what API you use, an 'XML object' are different things. In JDOM it would be an Element object, In SAX I don't believe you can manipulate objects like that since it's a read only API.

An XML document is one of the most commonly used data storage files. Look at it as an offline relational database like MySQL, with all the data in your XML File. Just like Java hierarchy, when building an XML doc you build a tree. I'm sure google can help you should you require more.

I don't thinks so. Method, which I should use, takes xml object, not a string.
Thanks though.

When you say "XML Object" what exactly do you mean - how if the method's parameter declared?

When you say "XML Object" what exactly do you mean - how if the method's parameter declared?

here is the method:

/**
     * Sets the p_DATAXMLTYPEIN value for this SVARCHAR2INSERT_RECEIVESInput.
     * 
     * @param p_DATAXMLTYPEIN
     */
    public void setP_DATAXMLTYPEIN(com.oracle.xmlns.orawsv.SISTEMA_MOKA.MGW_PUBLIC_FUNCTIONS.SVARCHAR2INSERT_RECEIVESInputP_DATAXMLTYPEIN p_DATAXMLTYPEIN) {
        this.p_DATAXMLTYPEIN = p_DATAXMLTYPEIN;
    }

one of the classes contains:

public class SVARCHAR2INSERT_RECEIVESInputP_DATAXMLTYPEIN  implements java.io.Serializable, org.apache.axis.encoding.AnyContentType {
    private org.apache.axis.message.MessageElement [] _any;

this method and some classes where generated using eclipse and wsdl file by creating web service client.
So I suppose it should involve smth org.apache.axis.message.MessageElement. How do I achieve it?

What exactly is the method supposed to do, and why didn't you code it yourself? I have no experience with generated code from eclipse, and the functions you gave above aren't very descriptive either, horrible naming aside.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.