Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-28-2008, 09:20 AM
jazz2k8's Avatar
Senior Member
 
Join Date: Apr 2008
Posts: 101
jazz2k8 is on a distinguished road
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...

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 :
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-28-2008, 03:08 PM
Senior Member
 
Join Date: Jul 2007
Posts: 134
brianhks will become famous soon enough
It is unclear from your post what is coming up 2 or 4 times? Can you please clarify?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-28-2008, 03:50 PM
jazz2k8's Avatar
Senior Member
 
Join Date: Apr 2008
Posts: 101
jazz2k8 is on a distinguished road
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 :
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-28-2008, 05:57 PM
Senior Member
 
Join Date: Jul 2007
Posts: 134
brianhks will become famous soon enough
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.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 04-29-2008, 08:33 AM
jazz2k8's Avatar
Senior Member
 
Join Date: Apr 2008
Posts: 101
jazz2k8 is on a distinguished road
thnx for ur reply..let me try the dom4j...
__________________
visit :
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +3. The time now is 12:57 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org