Results 1 to 5 of 5
Thread: XML help
- 04-28-2008, 08:20 AM #1
XML help
Hi Folks,
I am trying this code :
try {
FileHandler fh = new FileHandler("C:\\Documents and Settings\\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();
}
if i execute this for 2 times,it is coming up with 4 times:confused:...
What i am doing means i am extracting some values from an invoice..the root must be same but for every invoice
the xml should be appended with corresponding values when i execute the other invoice
like:
<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>visit : www.yoteam.co.cc
- 04-28-2008, 02:08 PM #2
Senior Member
- Join Date
- Jul 2007
- Posts
- 135
- Rep Power
- 0
It is unclear from your post what is coming up 2 or 4 times? Can you please clarify?
- 04-28-2008, 02:50 PM #3
the output is coming like this:
<?xml version.........>
<root>
<invoice Details>
<Invoice No>123</Invoice No>
<Invoice Amount>10000</Invoice Amount>
</invoice Details>
<?xml version.........>
<invoice Details>
<Invoice No>123</Invoice No>
<Invoice Amount>10000</Invoice Amount>
</invoice Details>
<?xml version.........>
<invoice Details>
<Invoice No>456</Invoice No>
<Invoice Amount>30000</Invoice Amount>
</invoice Details>
<?xml version.........>
<invoice Details>
<Invoice No>456</Invoice No>
<Invoice Amount>20000</Invoice Amount>
</invoice Details>
</root>visit : www.yoteam.co.cc
- 04-28-2008, 04:57 PM #4
Senior Member
- Join Date
- Jul 2007
- Posts
- 135
- Rep Power
- 0
I think the problem may lie in the code where you are writing the log messages. Can you post that?
Also it seems to me that you are using the logging system for something that it is not meant for. It looks like all you are trying to do is parse the invoice and create an XML from it. I would recommend either filling a dom (using dom4j) or just writing out using a SAX writer and sax events. Even simple is to just write directly to the FileWriter. In the later case all you need to do is come up with your own escape routine which is pretty simple.
My concern is that the logging mechanism is setup to do something different then what you want so you will most likely run into problems that you will have to work around and in the end would have been faster to just do one of the suggested techniques.
- 04-29-2008, 07:33 AM #5


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks