File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes reading data from XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "reading data from XML" Watch "reading data from XML" New topic

reading data from XML

yathish Gatty
Ranch Hand

Joined: Oct 05, 2004
Posts: 31

I am using SAX parser to parse the XML file and read the content.It works fine.But if it is large XML file about 1MB it takes 20-25 miniutes to parse it.The code that reads the data is given below.Can someone please suggest a solution to this.

String data="";
public void characters(char[] ch, int start, int length)
throws SAXException {

if (thisElement == "data") {

data = data+new String(ch, start, length);
System.out.println("Data :"+data);



Thanks in advance.

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
Parsing a 1MB file to grab the content of <data> elements should not take more than a few seconds as far as the parser actions are concerned. You must have other time consuming things going on, such as that System.out.print().
I agree. Here's the link:
subject: reading data from XML
It's not a secret anymore!