I am using xstream for parsing that is converting object to xml i have the below pojo along with setters and getter
public class InvoiceReferenceNotificationMessage {
private String InvoiceReference;
private String ABSReference;
private String Currency;
private double InvoiceAmount;
private double PaidAmount;
private double BalanceAmount;
private Date ValueDate;
private String Remarks;
}
and below i am using xstream to generate the xml in this fashion
public class InvoiceReferenceNotificationMessagetest {
InvoiceReferenceNotificationMessage invoiceReferenceNotificationMessage = new InvoiceReferenceNotificationMessage();
invoiceReferenceNotificationMessage.setInvoiceReference("SM/8315");
invoiceReferenceNotificationMessage.setABSReference("IRMAR157311");
invoiceReferenceNotificationMessage.setCurrency("GBP");
invoiceReferenceNotificationMessage.setInvoiceAmount(2546);
invoiceReferenceNotificationMessage.setPaidAmount(1245);
invoiceReferenceNotificationMessage.setBalanceAmount(0);
invoiceReferenceNotificationMessage.setValueDate(new Date());
invoiceReferenceNotificationMessage.setRemarks("abc");
XStream xstream = new XStream();
xstream.alias("invoiceReferenceNotificationMessage",InvoiceReferenceNotificationMessage.class);
String abc = xstream.toXML(invoiceReferenceNotificationMessage);
and the xml that is generated is in below fashion is ..
<invoiceReferenceNotificationMessage>
<InvoiceReference>SM/8315</InvoiceReference>
<ABSReference>IRMAR157311</ABSReference>
<Currency>GBP</Currency>
<InvoiceAmount>2546</InvoiceAmount>
<PaidAmount>1245</PaidAmount>
<BalanceAmount>0</BalanceAmount>
<ValueDate>2015-05-20 19:57:51.188 IST</ValueDate>
<Remarks>abc</Remarks>
</invoiceReferenceNotificationMessage>
now my query is that i want to generate the xml in the below fashion as shown below as you can see below that mail tag is parent tag and inside it there is subtag named invoiceReferenceNotificationMessage which contain all the information with respect to one block can you please advise how to achieve the same
<mail>
<invoiceReferenceNotificationMessage>
<InvoiceReference>SM/8315</InvoiceReference>
<ABSReference>IR311</ABSReference>
<Currency>GBP</Currency>
<InvoiceAmount>2546.0</InvoiceAmount>
<PaidAmount>1245.0</PaidAmount>
<BalanceAmount>0.0</BalanceAmount>
<ValueDate>2015-05-20 19:57:51.188 IST</ValueDate>
<Remarks>abc</Remarks>
</invoiceReferenceNotificationMessage>
</mail>