Click to See Complete Forum and Search --> : How to Create and Append My Xml


jazz2k2
04-28-2008, 03:26 AM
I want to create an xml and the results should be appended to the same xml file under the root tag.

EG:

<root>
<Invoice Details>
<invoiceNo>1234</invoiceNo>
<invoice Date>12-mar-2008 </invoice Date>
<Amount>10000</Amount>
</InvoiceDetails>
<Invoice Details>
<invoiceNo>5678</invoiceNo>
<invoice Date>12-mar-2008 </invoice Date>
<Amount>20000</Amount>
</InvoiceDetails>
</root>


I have written code like this:
try {
FileHandler fh = new FileHandler("C:\\Documents and Settings\\praveen.v\\Desktop\\test\\logfile.xml",true);
XMLFormatter xmlf = new XMLFormatter();
fh.setFormatter(xmlf);
Logger logger = Logger.getLogger("test.test1.test2");
logger.addHandler(fh);
logger.setLevel(Level.ALL);
logger.warning("that is a test log message -- Level WARNING");
logger.info("that is a second test log message -- Level WARNING");
}
catch (Exception e) {
e.printStackTrace();
}

It is giving Error...wats the soln???

Hack
04-28-2008, 02:21 PM
What is the error that is given?

jazz2k2
04-29-2008, 12:26 AM
?xml version="1.0" encoding="UTF-8" standalone="no"?>
<root>
<fileName Updated="N">
<Buyers_Order_No>ATSPLJECP/KAR/083</Buyers_Order_No>
<Date>24-Jan-2008</Date>
<Invoice_No>Feb 08/Pur/18</Invoice_No>
<Invoice_Date>12-Feb-2008</Invoice_Date>
<VAT_TIN> Applicable</VAT_TIN>
<TAX_NO> 27080336785</TAX_NO>
</fileName>
</root>

<root>
<fileName Updated="N">
<Buyers_Order_No>ATSPLJECP/KAR/083</Buyers_Order_No>
<Date>24-Jan-2008</Date>
<Invoice_No>Feb 08/Pur/18</Invoice_No>
<Invoice_Date>12-Feb-2008</Invoice_Date>
<VAT_TIN> Applicable</VAT_TIN>
<TAX_NO> 27080336785</TAX_NO>
</fileName>
</root>:SICK:

Hack
04-29-2008, 01:03 PM
Ok, but you said you were getting an error? What is the error?

jazz2k2
05-02-2008, 12:46 AM
Dont you find my error...???

<root> is coming for every new execution????