• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

extracting data from XML file using servlets

 
Sri Sar
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i have a XML file as given below:
<main>
<ele id="1">C:\My Documents\data1.txt">
<ele id="2">C:\My Documents\da2.txt">
</main>
the text files contains some names and a number for each name like
sam 29
chris 32 etc
i want the pseudo-code using which i can use a servlet to extract the data present in the files "data1.txt" and "da2.txt" and then perform calculations on them like multiplying the values in the text files.
thanks in advance
 
Basavaraju Banakar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Step1.
Use SAX parser for reading the path from XML file
step2.
Read files using java.io package....
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why use SAX when DOM is a lot easier to use?
I know SAX is a bit more memory efficient but unless you're loading megabytes of data at a time that doesn't matter and the faster coding when using DOM more than pays for itself.
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For me DOM working great even for xml file which is 1855kb, but I am using MSXML parser
No 100% CPU usage and very fast.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic