I defined a class as the following:
public class VendorQueryRq {
        private int requestID;

        public int getRequestID() {
                return requestID;
        }
}
Then I am using the following code to covert the instance into xml:

        StringWriter outputWriter = new StringWriter(); 

        BeanWriter beanWriter = new BeanWriter(outputWriter);
        
        beanWriter.enablePrettyPrint();
        beanWriter.getBindingConfiguration().setMapIDs(false);

        VendorQueryRq request = new VendorQueryRq();
        request.setRequestID(11);
        msgsRq.setVendorQueryRq(request);

        beanWriter.write(request);
        System.out.println(outputWriter.toString());

Here is the output:
  <VendorQueryRq>
    <requestID>11</requestID>
  </VendorQueryRq>

The output is good, which uses class name as tag name(VendorQueryRq).

Then I defined another class, which includes one VendorQueryRq attribute:
public class QBXMLMsgsRq {
        private String onError;

        private VendorQueryRq request;

        public String getOnError() {
                return onError;
        }

        public void setOnError(String onError) {
                this.onError = onError;
        }

        public VendorQueryRq getVendorQueryRq() {
                return request;
        }

        public void setVendorQueryRq(VendorQueryRq request) {
                this.request = request;
        }
}
Then I use the following code to print out xml:
        StringWriter outputWriter = new StringWriter(); 
        BeanWriter beanWriter = new BeanWriter(outputWriter);
        
        beanWriter.enablePrettyPrint();
        beanWriter.getBindingConfiguration().setMapIDs(false);

        QBXMLMsgsRq msgsRq = new QBXMLMsgsRq();
        msgsRq.setOnError("stopOnError");

        VendorQueryRq request = new VendorQueryRq();
        request.setRequestID(11);
        msgsRq.setVendorQueryRq(request);

        beanWriter.write(msgsRq);
        
        System.out.println(outputWriter.toString());

Now, xml output is the following:
 <QBXMLMsgsRq>
    <onError>stopOnError</onError>
    <vendorQueryRq>
      <requestID>11</requestID>
    </vendorQueryRq>
  </QBXMLMsgsRq>

But it use <vendorQueryRq> instead of <VendorQueryRq>, How can I change 
<vendorQueryRq> into <VendorQueryRq>?

Thanks a lot.



      __________________________________________________________________
Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your 
favourite sites. Download it now at
http://ca.toolbar.yahoo.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to