I defined the following two classes and used the following code to get XML 
string. 

Here is the one result:
<InvoiceMod>
          <InvoiceLineModList>
            <InvoiceLineMod>
              <Quantity>11</Quantity>
              <TxnLineID>aa</TxnLineID>
            </InvoiceLineMod>
          </InvoiceLineModList>
          <TxnID>1-1231787678</TxnID>
        </InvoiceMod>

For List attribute, I do not want to have <InvoiceLineModList>. How can I 
define InvoiceMod.betwixt?

Thanks a lot.
Arden


=================================================================

                StringWriter outputWriter = new StringWriter();

                // Betwixt just writes out the bean as a fragment
                // So if we want well-formed xml, we need to add the prolog
                outputWriter.write("<?xml version=\"1.0\"?>");
                // Create a BeanWriter which writes to our prepared stream
                BeanWriter beanWriter = new BeanWriter(outputWriter);

                // Configure betwixt
                beanWriter.enablePrettyPrint();
                beanWriter.setWriteEmptyElements(false);
                beanWriter.getBindingConfiguration().setMapIDs(false);
                
beanWriter.getXMLIntrospector().getConfiguration().setElementNameMapper(new 
CapitalizeNameMapper());


                beanWriter.write(qbXmlBean);

                String xmlString =  outputWriter.toString();

=================================================================
public class InvoiceMod {
        private String txnID;

        private List<InvoiceLineMod> invoiceLineModList = new 
ArrayList<InvoiceLineMod>();
        
        public String getTxnID() {
                return txnID;
        }

        public void setTxnID(String txnID) {
                this.txnID = txnID;
        }
        
        public List<InvoiceLineMod> getInvoiceLineModList() {
                return invoiceLineModList;
        }

        public void addInvoiceLineMod(InvoiceLineMod invoiceLineMod) {
                invoiceLineModList.add(invoiceLineMod);
        }
        
}

public class InvoiceLineMod {
        private String txnLineID;
        private Integer quantity;

        public String getTxnLineID() {
                return txnLineID;
        }

        public void setTxnLineID(String txnLineID) {
                this.txnLineID = txnLineID;
        }

        public Integer getQuantity() {
                return quantity;
        }

        public void setQuantity(Integer quantity) {
                this.quantity = quantity;
        }
}


      __________________________________________________________________
Looking for the perfect gift? Give the gift of Flickr! 

http://www.flickr.com/gift/

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

Reply via email to