This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "reading data from XML" Watch "reading data from XML" New topic
Author

reading data from XML

yathish Gatty
Ranch Hand

Joined: Oct 05, 2004
Posts: 31
Hi,

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.

Regards,
Yathish.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12756
    
    5
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().
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: reading data from XML
 
Similar Threads
Dynamic Column List?
Java And OpenDocument Files
Missing characters with SAX Parser
character method of ContentHandler
Loading XML Files into Android App